Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How to push the previous line based on the current line to two different files.

by davido (Archbishop)
on Sep 13, 2012 at 06:26 UTC ( #993376=note: print w/ replies, xml ) Need Help??


in reply to How to push the previous line based on the current line to two different files.

Untested, but it should get you going in the right direction.

open my $code_fh, '>', 'codefile.txt' or die $!; open my $var_fh, '>', 'varfile.txt' or die $!; open my $in_fh, '<', 'infile.txt' or die $!; local $/ = "\n\n"; while ( <$in_fh> ) { print { m/^\s+DC\s+/m ? $var_fh : $code_fh } $_; } close $var_fh or die $!; close $code_fh or die $!;

Dave


Comment on Re: How to push the previous line based on the current line to two different files.
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (13)
As of 2015-07-08 02:46 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 (93 votes), past polls