Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Help with splitting one text file into other text files

by moritz (Cardinal)
on Mar 30, 2011 at 15:30 UTC ( #896441=note: print w/ replies, xml ) Need Help??


in reply to Help with splitting one text file into other text files

You can store file handles in hashes, something like

use autodie; my %handles; for (1996..2011) } open $handles{$_}, '<', "$_.sec"; } ... print { $handles{$year} } $yourdata;


Comment on Re: Help with splitting one text file into other text files
Download Code
Re^2: Help with splitting one text file into other text files
by Fletch (Chancellor) on Mar 30, 2011 at 15:35 UTC

    Depending on the OS and the number of simultaneous handles you need FileCache might also be of interest.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      Or FileCache::Handle, but what is really needed, is a lexically scoped pragma like autodie, so you can
      use autofilecache; use autodie; my @Fs; for(1..1024){ open my($f),'<',$_; push @Fs, $f; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://896441]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2015-07-02 22:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (46 votes), past polls