Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: Splitting a text file

by Ratazong (Monsignor)
on Mar 20, 2013 at 08:06 UTC ( #1024470=note: print w/replies, xml ) Need Help??


in reply to Re^2: Splitting a text file
in thread Splitting a text file

Hi Dr Manhattan,

have a look at the difference between my algorithm and your solution: you open the file in each iteration of the loop. And by opening a file for writing, you erase the previous content.

The solution is to open the file before the loop. And (additionally) inside the if-block, when you want to switch to the next file.

HTH, Rata

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024470]
help
Chatterbox?
[ikegami]: That should be ${ $hash{$key} }[$_] because it's $a[$_] when you don't use a ref.
[oiskuu]: James, that's an array slice you have there (over some hash value)
[ikegami]: Mini-Tutorial: Dereferencing Syntax

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2017-04-27 19:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (512 votes). Check out past polls.