is wrong, because the parser subroutine has not been declared at this point and the Perl compiler does not know yet what parser is supposed to be.parser $_;
So either you give the compiler a clue that it is a subroutine call by putting the argument between parentheses:
or you define the parser subroutine beforehand:parser($_);
which will duly print Hello, world a number of times.use strict; use warnings; sub parser { print "Hello, world\n"; } open INFILE, '<', $0; while (<INFILE>) { chomp; parser $_; } __END__
You could even define your parser subroutine afterwards as in your code, provided you pre-declare it before you use it:
Note: all my three suggested corrections above run correctly under Windows.use strict; use warnings; sub parser; open INFILE, '<', $0; while (<INFILE>) { chomp; parser $_; } sub parser { print "Hello, world\n"; } __END__
In reply to Re: perl 5 interpreter crashes
by Laurent_R
in thread perl 5 interpreter crashes
by pmclot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |