http://qs321.pair.com?node_id=661300


in reply to line by line match on an array of strings

Hi barryscott

This may also help you in addition to j1n3l0

use strict; my @typedefs = qw(do re me fa so la ti do); while (my $line = <DATA>) { chomp($line); if(grep/$line/, @typedefs){ print "$line\n"; ## perform various actions here if line match } } __DATA__ do me a favour will you

Punitha

Replies are listed 'Best First'.
Re^2: line by line match on an array of strings
by ww (Archbishop) on Jan 09, 2008 at 14:13 UTC

    May not be the OP's intent???

    prints
    do me a

    Update (after what I judge to have been too many minutes of puzzling over this)

    Still not clear why "a" matched (it'll come to me yet), but the obvious cure (IMO) is to anchor the match, thus

    if(grep/^$line$/, @typedefs){