Perl Look for string in file

Hi Guys

In perl how can i look for a string in side a file and return something if it exists

a little bit of background i have made a wrapepr for a program but in order for the program to work i need to modify a file first, i want to stick something in the wrapper that will tell if the sting in the file exists so i know to modify it first

for exmaple the sting is "/usr/lib" and "/usr/lib/boost"

thanks

A

Since you haven't mentioned what that "something" is, I'll assume you want to see a message that says the string exists in the file.

$
$ cat f15
Twinkle twinkle little star
Mary had a little lamb
Little Bo Peep
London bridge is falling down
Hickory Dickory Dock
$
$ perl -lne '/lamb/ and print "lamb is present in the file"' f15
lamb is present in the file
$
$ perl -lne '/little/ and print "little is present in the file"' f15
little is present in the file
little is present in the file
$
$ perl -lne '/Humpty/ and print "Humpty is present in the file"' f15
$
$

tyler_durden