Please don't top post. I think you've been asked this before.
On 8/2/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> ok I understand now...thanks, but I tried it and it is still stopping at
> original1.1
> I then modified it to print YESSSS if ($1) but never saw YESSSS in STDOUT.
Tha's because as a one liner it doesn't use parentheses. And also
becuase YESSSSS isn't a string, it's a constant. Do you have warnings
turned on? warnings and strict would catch these sorts of things.
print "Yes" if $1; # or
if ($1) {print "Yes"}
Your choice.
> > #!/usr/bin/perl
> > use strict;
> > use warnings;
> >
> > while (<DATA>) {
> > if (/AA/ ... /(CC)/) {
> > print;
> > if ($1) {
> > while (<DATA>) {
> > # this regex defines when your section is done
> > last if /^\s*$/;
> > print;
> > }
>
> # so you don't have to spin over the rest of the file
> last;
>
> > }
> > }
> > }
I think we need a clearer description of what you want to do here. At
least I do. will your last line have "original.1"? Or will it have
something else? i don't think anyone knows what "the "end of
original.1" means. "original.1" is a string, and the current code
matches that string. If you need to match the end of the string, use
'/original\.1$/'.
I think, though that you mean the end of some block of lines in your data file.
It looks to me like you want something along the lines of :
while(<>) {
if (/allsets/ .. /original\.1/) {
print;
} elsif (/media/ .. /Total/) {
print;
}
}
-- j
--------------------------------------------------
This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
private and confidential
daggerquill [at] gmail [dot] com
http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>