*** code pasted below, chatter up above ****
Hello all,
Im relatively new to perl so I hope this question doesnt insult anyone.
Im parsing a file and i will need to find one particular line based on a word and then the rest of that file ill need to be able to parse it again. If anyone has a good way of doing this I would love to hear it .. so far I can only create a "marker" that I have found the line and from there create a new array.
1) is there a way to do "@new_array = array that is left".. a pop from the front of the array if you will
or
2)is there a better conditional loop to use ... i thought of while/until but that doesnt seem to work in this case
or
3) someone have a much better way of doing this???? :)
*** code ****
while (<FILE>){
my @arr_hold=$_;
foreach my $guide (@arr_hold){
if ( $guide =~ /PAGE: 2/){
$var = 1;
}
if ($var == "1"){
print FILE2 "$guide";
push (@new_arr,$guide);
}
}
foreach (@new_arr){
print $_;
}
}
Thanks.
R.
Edit Masem 2002-01-23 - Title modified from "newbie question"
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.