Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Want to get regexp list from file

by ambs (Pilgrim)
on Mar 26, 2005 at 19:53 UTC ( #442552=note: print w/replies, xml ) Need Help??


in reply to Want to get regexp list from file

Hi.

Regarding your post, try to add <pre>..</pre> around the code.

Regarding your problem, try something like:

my $regexp = shift; my $text = shift; open RE, $regexp; while(<RE>) { chomp; push @re, $_ } close RE; open TXT, $text; while(<TXT>) { for my $re (@re) { print if m!$re! } } close TXT
Sorry but I didn't test the code, but I hope this helps. Good luck.

Update: Thanks to ambrus for correcting my code.

Alberto Simões

Replies are listed 'Best First'.
Re^2: Want to get regexp list from file
by ambrus (Abbot) on Mar 26, 2005 at 20:39 UTC
    for my $re (@re) { print if m!re! }

    I guess you're missing a dollar sign before re.

Re^2: Want to get regexp list from file
by Fletch (Chancellor) on Mar 27, 2005 at 01:12 UTC
    Regarding your post, try to add <pre>..</pre> around the code.

    Erm, ITYM add <code>...</code>.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://442552]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2021-10-27 12:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (93 votes). Check out past polls.

    Notices?