Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: 'Anonymous' copy via file handle fails

by Anonymous Monk
on Jan 17, 2013 at 00:02 UTC ( #1013664=note: print w/replies, xml ) Need Help??


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
    Hmmm. The strange thing is I actually had a 'rewind' in there at some point but removed it again because it didn't have any impact. However if I change the first copy operation to
    copy $src_file, $tmp1_fh or die "$ERRNO\n"; seek $tmp1_fh,0,0;
    then it magically works now. Thanks for the tip! Maybe there is some other bug lurking in the original program, but now that the basic copy works I'm sure to figure it out.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1013664]
help
Chatterbox?
[1nickt]: Corion HPs? ugh. I was impressed with Lenovo's gaming laptops; if it weren't for the red backlighting and general flashiness of the aesthetic, I might have gone with that. But all that was until I discovered that the Dell Precision line is still around.
[1nickt]: stevieb I don;t doubt that there's a difference. BestBuy has "consumer" models only on display.
[ambrus]: 1nickt: for some reason, these days they call every computer "gaming", even ones that gamers wouldn't buy. I've bought a keyboard that was labelled "gamer", despite that it has hard springs and seems to be way better for typing than for gaming;
[1nickt]: I though the gamers like that because they bash the keys so hard.
[ambrus]: and I've seen motherboards with no fast expansion ports for a video card but built-in hardware RAID advertized as "gaming".
LanX has a shaming laptop
[ambrus]: 1nickt: my impression is that the gamers like the softer springs, because fast reaction time is more important to them then feedback from keypresses to recognize typos.
[1nickt]: Ah, I see. I did read some gamer mag reviews, and yes, they lamented the fact that laptops with no discrete video card are sold as "gaming" hardware.

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (14)
As of 2017-03-27 13:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.