in reply to 'Anonymous' copy via file handle fails
Filehandles are iterators. Once you reach the end, you're at the end, subsequent read/readline reads from the end, there is nothing at the end, so you have to use seek to rewind the FA filehandle before you read it again.
$ echo > 1 $ perl -MFile::Copy -wE " open $O, 1 or die $!; sub F{copy $O, \*STDOU +T } F;F; seek $O,0,0; F; " ECHO is on. ECHO is on. $ rm 1 $
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: 'Anonymous' copy via file handle fails
by Monk::Thomas (Friar) on Jan 17, 2013 at 08:51 UTC |
In Section
Seekers of Perl Wisdom