in reply to what is the return value
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: what is the return value
by choroba (Cardinal) on Jul 09, 2013 at 13:52 UTC | |
by Skeeve (Parson) on Jul 09, 2013 at 14:01 UTC | |
by choroba (Cardinal) on Jul 09, 2013 at 14:36 UTC |