Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: what is the return value

by Skeeve (Vicar)
on Jul 09, 2013 at 13:49 UTC ( #1043318=note: print w/ replies, xml ) Need Help??


in reply to what is the return value

That code won't work.

Put "use strict; use warnings;" in

use strict; use warnings; sub firstline { open (my $in, shift) && return scalar <$in>; # no close() required } print firstline("/etc/hosts");
and you'll get:
Global symbol "$in" requires explicit package name at firstline.pl lin +e 4. Execution of firstline.pl aborted due to compilation errors.
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.

s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e


Comment on Re: what is the return value
Select or Download Code
Replies are listed 'Best First'.
Re^2: what is the return value
by choroba (Canon) on Jul 09, 2013 at 13:52 UTC
    Works for me.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Maybe different perl version?
      $ perl -v This is perl 5, version 14, subversion 2 (v5.14.2) built for cygwin-th +read-multi-64int (with 7 registered patches, see perl -V for more detail) Copyright 1987-2011, Larry Wall Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5 source ki +t. Complete documentation for Perl, including FAQ lists, should be found +on this system using "man perl" or "perldoc perl". If you have access to + the Internet, point your browser at http://www.perl.org/, the Perl Home Pa +ge.

      s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
      +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
        No, the update was the reason.
        لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043318]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (16)
As of 2015-07-31 21:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (282 votes), past polls