Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: searching using a scalar as pattern

by Masem (Monsignor)
on Jan 18, 2002 at 21:07 UTC ( #139867=note: print w/ replies, xml ) Need Help??

in reply to searching using a scalar as pattern

Basically, once you have your $name, you want to see where it appears in a second file. This step is equivalent to using the unix 'grep' to search through a file, and if you have that installed, you could simply use a system command to get the results. But a more portable solution would be to load in the text file, and use perl's built-in grep to find your string:

open FILE, "<$inputFileName" or die "Cannot open: $!"; my @lines = <FILE>; my @matched_lines = grep { /$name/ } @lines; close FILE;

Dr. Michael K. Neylon - || "You've left the lens cap of your mind on again, Pinky" - The Brain
"I can see my house from here!"
It's not what you know, but knowing how to find it if you don't know that's important

Comment on Re: searching using a scalar as pattern
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2015-12-01 15:03 GMT
Find Nodes?
    Voting Booth?

    My keyboard shows this many letters:

    Results (12 votes), past polls