Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

dbrock's scratchpad

by dbrock (Sexton)
on Apr 21, 2009 at 15:16 UTC ( [id://759014]=scratchpad: print w/replies, xml ) Need Help??

I am currently trying to find out if I can "chomp" (or another command) multiple lines once I find what ever im searching for... I'm currently opening a ascii text file sending it to an array... Then while in a for loop i am reading each element of the array... for($i=0;$i<@txtfile;$i++) { what I have run into is that inside of the text file that I'm reading, i have many lines that have the same data... Currently i'm using the chomp command to find and set the variables i need...
##### Get Keyword Variable ##### if ($txtfile[$i] =~ /\bKeyword:/) { chomp ($keyword = $txtfile[$i]); $keyword =~ s/Keyword: //; #print "$keyword\n"; }
is there a way to chomp / capture multiple lines while i'm already in the for loop incrementing each line... so as example i would like to capture the following data from example below... (each "Include:" seperatley) text file excerpt:
Client/HW/OS/Pri: natsciexevs19 PC WindowsNET 0 0 0 0 ? Include: Microsoft Information Store:\SG1 Include: NEW_STREAM Include: Microsoft Information Store:\SG2 Include: NEW_STREAM Include: Microsoft Information Store:\SG3 Exclude: (none defined)
I would like to capture each of the "Include:" lines and set them to $include1 , $include2 , $include3 etc... the problem i continue to run into is that I over write my variable with the second instance of "Include"...
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2024-04-23 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found