Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: pattern match on entire file

by CubicSpline (Friar)
on Nov 14, 2001 at 18:26 UTC ( [id://125308]=note: print w/replies, xml ) Need Help??


in reply to pattern match on entire file

Howdy. You're almost there, it's just the way you're using the file that's giving you trouble. You should open the file once for reading, slurp in the @file array, close the file, and then open it again for appending (if necessary) to write the $tempName var. I'd think you'd want something like this:

$tempName= $query->param('searchText'); #user supplied open (FILE, "filename"); @file = <FILE>; close FILE; $temp = join('',@file); $temp =~ /$tempName/s; if ($temp eq '') { open FILE, ">>filename"; print FILE $tempName . "\n"; } close (FILE);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-23 13:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found