Link to home
Start Free TrialLog in
Avatar of msknr
msknr

asked on

string searching

here is what I want to do...


I have a flat file db with the following...


"Ryan","ryan@ryan.com"
"Bill","bill@bill.com"

etc....

I want to remove an entry by email address... what can I use to test if ryan@ryan.com is in a line, if so remove it.

open(file,"/path/data.dat");
@data = <file>;
close(file);

open(newfile,">path/data.dat");

foreach $line (@data) {

chop($line);

if (!($line contains ryan@ryan.com)) {
 print newfile "$line\n";

}
close(newfile);


thanks!
Avatar of ozo
ozo
Flag of United States of America image

if( !($line =~ /\Qryan@ryan.com\E/) ){
    print newfile "$line\n";
}
ASKER CERTIFIED SOLUTION
Avatar of jhurst
jhurst

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial