Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: tripping over filehandle / subroutine usage

by LanX (Chancellor)
on Dec 21, 2012 at 21:43 UTC ( #1009962=note: print w/replies, xml ) Need Help??


in reply to tripping over filehandle / subroutine usage

just a guess:

if your FH is at EOF after the first subroutine you should reset the position to start using seek before expecting to read again in another sub.

UPDATE:

ok, now that you updated code it seems like my guess was right:

my @rows = (<$input_handle>);

exhausts your filehandle.

BTW you should consider working with something like

while ( my $line = <$input_handle>) {
to read line by line, when working with large files, because otherwise you're consuming lots of RAM.

Cheers Rolf

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009962]
help
Chatterbox?
[Eily]: (perl with hearts, 'Acker with a French accent is pronunced like coeurs)
[LanX]: IMHO 'ju' for 'u' happens in English where they can't pronounce the French u (or German )
[LanX]: and I'm sure I read that *hotel* used to be pronounced 'otel by the English upperclass
[Your Mother]: American English vowels are pretty lazy/mumbly in general.
[LanX]: talking about antisemitism, youtube automatic subtitles is entertaining shocking sometimes ... like when offering "Fruit Jews" as a drink
[Your Mother]: ...Come on you King of the Juice...
[Your Mother]: I actually know his kids.
LanX has to go/
[Your Mother]: King Herod's song (Mike D'Abo performed, I think)

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2017-03-27 17:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.