Syntactic Confectionery Delight | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Firstly, it's broken. The # marks a comment, so the closing } will be ignored and break the code.
Looking at:
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
|
|