Firstly, it's broken. The # marks a comment, so the closing } will be ignored and break the code. Looking at:
1 sub firstline { 2 open( my $in, shift ) 3 && return 4 scalar <$in>; 5 # no close() required 6 }
line 1: starting a new sub called 'firstline'
Line 2: (from right to left)
    shift: gets the first parameter passed to the sub
    $in: is just a variable
    my $in: says $in only exists in this sub
    open: open a file. In this case the file name is the first parameter to the sub, and $in becomes the handle
line 3: &&: A logical-and ensure that if the file open fails, the next command will be skipped.
    return: return the following data
line 4: scalar: tells perl to think of the next 'thing' as a single line of text.
    <$in>: read from the file handle. Combined with the 'scalar' instruction will get just one line.
line 5: a comment noting that the file is automatically closed when the $in filehandle 'dissapears' at the end of the sub.
line 6: ending the sub.

So.. Line 2 opens a file. Line 4 gets a single line of text and Line 3 returns that single line.

Try reading http://perldoc.perl.org/perlopentut.html and other tutorials.

In reply to Re: what is the return value by The_Dj
in thread what is the return value by arasumg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.