That code won't work.
Put "use strict; use warnings;" in
and you'll get:use strict; use warnings; sub firstline { open (my $in, shift) && return scalar <$in>; # no close() required } print firstline("/etc/hosts");
If you don't use strict/warnings, you'll simply get an empty line. Update: Removed the "; 1 " which I putted in to make the code at least print out something.Global symbol "$in" requires explicit package name at firstline.pl lin +e 4. Execution of firstline.pl aborted due to compilation errors.
In reply to Re: what is the return value
by Skeeve
in thread what is the return value
by arasumg
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |