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

Re^2: splitting file with mutiple output filenames

by Anonymous Monk
on Apr 11, 2012 at 09:24 UTC ( [id://964484]=note: print w/replies, xml ) Need Help??


in reply to Re: splitting file with mutiple output filenames
in thread splitting file with mutiple output filenames

I'd suggest to use while(<FH>) instead of foreach(<FH>). (while loop reads directly from file, for(each) loop slurps the entire file into memory first - really bad for huge files, but ok for small ones).

Maybe something like this:
use strict; use warnings; open my $thai_fh, '<:utf8', "thaikjv-fixed.txt" or die $!; while(<$thai_fh>){ if (/^@(...\d\d\d)/) { open my $out_fh, '>:utf8', "$1.html" or die $!; print {$out_fh} $_; } }
/code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-19 13:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found