Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: line by line match on an array of strings

by Punitha (Priest)
on Jan 09, 2008 at 10:13 UTC ( #661300=note: print w/replies, xml ) Need Help??

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


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???

    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){

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://661300]
[stevieb]: I'm learning that no matter how good a piece of software is at what it's supposed to do, it's a piece of shit without providing any API documentation. (Talking about C++ here currently). Seriously... write software for an embedded platform and make...
[stevieb]: guess based on the sparse examples, and the header files that are spread out illogically?
[stevieb]: document the public facing functions/methods people... ALL OF THEM.

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2017-05-28 23:43 GMT
Find Nodes?
    Voting Booth?