Yes, grep has some great benefits if used properly!  Unfortunately a lot of
people, myself included up until a couple of months ago, either don't know
about or how to use it.  I didn't figure I would throw it out there since
there was already some confusion :-)

Shawn

> Or in a shorter way:
> -------------------------------
> open (FH, "<test.txt") || die $!;
> my @lines = <FH>;
> for (@lines) {chomp};
> my $line_with_b = grep{ $lines[$_] eq 'b' && $lines[$_+1] eq
> 'c'}0..$#lines;
> print "Line containing b is: $line_with_b\n";
> close FH;
>
> ----------------------------
> test.txt:
> a
> b
> c
> d
> e
> f
>
>
> _______________________________________________
> ActivePerl mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/activeperl
>
>

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl

Reply via email to