How do you search a file in Perl?

tim85a

New member
I'm trying to get Perl to search a file for a string held in $data and if its not found print it into the file. The code I've got at the moment is:

open FILE, 'list.txt';
while ( my $data = <DATA> ) {
$data =~ s/(.)(+)/$1.length($1.$2)/ge;
print $data;
}

close FILE;

but it prints $data still so there is two in the file :( I don't mind if it rights over $data with $data or dies, whichever makes a smaller and simpler program. It has to be a match for all of $data, not just part of it.

Thanks for your help.
 
Back
Top