BTW: John W. Krahn suggested I can change Input Record Separator, it does work and help me to solve the problem! But I just wonder why the following program can not work very well and what's wrong with it!. Thanks very much!
# there is a trailing record separator "\n" at end of every elemnet
my @items = qw(
>blue
sky
skirt
sea
>common_white
paper
flower
feather
>red
face
flower >milk_white
milk
ivory
>green
grand
tree
);
my $after_white;
foreach my $item ( @items ) { $after_white = 1 if $item =~ /white$/; if ( $after_white ) { print "$item\n"; next if $item =~ /^>/; $after_white = undef; } } __END___
The results given like this, it seems the loop works only for one time
>common_white paper >milk_white milk
:-)THANKS
Charles K. Clarkson wrote:
my @items = qw( >blue sky skirt sea >white paper flower >red face flower >green grand tree );
my $after_white; foreach my $item ( @items ) {
if ( $after_white ) { last if $item =~ /^>?red$/; print "$item\n"; }
$after_white = 1 if $item =~ /^>?white$/; }
__END__
HTH,
Charles K. Clarkson
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>