[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: passes syntax but xchat crashes
D. Hoyem writes:
> $msg = shift(@_);
> $nick = $msg;
my ($msg) = @_;
turn on -w.
> if (length ($nick) > 9) {
> then (length ($nick) eq "'$nick'");}
There is no 'then' in Perl. If there was, it wouldn't be inside the
block.
Suggestion: do *not* use perl -c to test your script. Example:
; perl -wce 'this_sub_no_exist();'
-e syntax OK
; perl -we 'this_sub_no_exist();'
Undefined subroutine &main::this_sub_no_exist called at -e line 1.
[nonzero status 1]
Type ``perl -w <yourscript.pl>''. If you see ``Undefined subroutine
IRC::foo'', then it compiled and you are OK. If not, then there was a
compilation error.
If you would rather not see the undefined sub message, use IRC.pm. I
have written an improved version which I will attach (whoever
maintains the scripts page, please take a look.)
> elsif (length ($nick) == 0) {
> then (length ($nick) eq " '$nick' ");}
Yuck. assumeing we get rid of 'then', we get:
if (length ($nick) == 0) { length ($nick) eq " '$nick' ";}
the statment in the block does not *do* anything: it's a boolean test.
assuming you want to add spaces:
my $newnick = sprintf "%11s", "'$nick'";
if ($newnick =~ /^\s+/) {
my $padding = substr $newnick, 0, length($&)/2, '';
$newnick .= $padding;
}
--
There is no TRUTH. There is no REALITY. There is no CONSISTENCY. There
are no ABSOLUTE STATEMENTS. I'm very probably wrong. -- BSD fortune(6)
IRC.pm