Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Reading and unpacking on one lineby choroba (Cardinal) |
on Nov 05, 2020 at 16:19 UTC ( [id://11123428]=note: print w/replies, xml ) | Need Help?? |
From read: > Returns the number of characters actually read, 0 at end of file, or undef if there was an error Therefore, the second version is equivalent to
because the read returned 16. If you only specify the template, unpack uses the default variable $_ as the value to unpack. You can use do to read and return the value you have just read:
But you should check what read returned to handle possible errors. Also, calling a file handle FILNAM, which rather seems to be an abbreviation of "file name", is misleading.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
In Section
Seekers of Perl Wisdom
|
|