http://qs1969.pair.com?node_id=1043235


in reply to what is the return value

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.