F
fatted
Lets say a friend of mine
wrote code which had a bad error in it:
#!/usr/bin/perl
use warnings;
use strict;
my $words = ["a", "b", "c"];
my $num = 612;
if($num == 1)
{
print "moo\n";
}
elsif (map($_->[0] =~ /\d{6}/, @$words))
{
print "Don't give up day job\n";
}
When run this gives the error:
Can't use string ("a") as an ARRAY ref while "strict refs" in use at
../test.pl line 8.
After about 1/2 hour of head banging, the problem (which was
originally in a much larger program) was finally discovered. The code
problem wasn't on line 8
. I have fixed that and slapped my "friend"
around the face for stupidity.
However this leads to my real question:
Is the error message above, an error in the compiler? For instance if
the close bracket of an elsif is forgotton, you get an error on the
line where the close bracket was left out. *Not* on the line where the
start of the IF THEN ELSE syntax began.
e.g. if I fixed line 8 to (oops left out close bracket for elsif):
elsif (map(/\d{6}/, @$words)
Error message is:
syntax error at ./test.pl line 14, near ")
{"
Execution of ./test.pl aborted due to compilation errors.
#!/usr/bin/perl
use warnings;
use strict;
my $words = ["a", "b", "c"];
my $num = 612;
if($num == 1)
{
print "moo\n";
}
elsif (map($_->[0] =~ /\d{6}/, @$words))
{
print "Don't give up day job\n";
}
When run this gives the error:
Can't use string ("a") as an ARRAY ref while "strict refs" in use at
../test.pl line 8.
After about 1/2 hour of head banging, the problem (which was
originally in a much larger program) was finally discovered. The code
problem wasn't on line 8
around the face for stupidity.
However this leads to my real question:
Is the error message above, an error in the compiler? For instance if
the close bracket of an elsif is forgotton, you get an error on the
line where the close bracket was left out. *Not* on the line where the
start of the IF THEN ELSE syntax began.
e.g. if I fixed line 8 to (oops left out close bracket for elsif):
elsif (map(/\d{6}/, @$words)
Error message is:
syntax error at ./test.pl line 14, near ")
{"
Execution of ./test.pl aborted due to compilation errors.