Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Parsing file to pull out sections of text

by artist (Parson)
on Feb 03, 2009 at 20:46 UTC ( #741121=note: print w/replies, xml ) Need Help??


in reply to Parsing file to pull out sections of text

use strict; use warnings; my $flag = 0; my $start = 'd1'; my $end = 'd4'; my @array; while (<DATA>) { chomp; if(/$start/){ $flag = 1; @array = (); } elsif(/$end/) { $flag = 0; print "@array\n"; } else{ push @array, $_ if $flag; } }
--Artist

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://741121]
help
Chatterbox?
[Corion]: Whoops - more spam - I guess I'll have to collate a list and have them banned later today
[Corion]: Maybe I should bring my Github credentials to $work some day, just to open issues for blogs.perl.org ;)

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2017-02-24 11:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (354 votes). Check out past polls.