[Perl] RE: Question

Gabor Szabo gabor at tracert.com
Wed Jun 5 03:29:27 PDT 2002


> 
> But I don't need it from the unix prompt , I can use simple sed for that .
> 
> I need to write in a simple script in perl .
> 
> Can you help ?
Sure though if you look at the documentation I mentioned 
I think you can already write it.

Here is one solution.

$filename = "Temp.c";  # holds the name of your file where do you get it 
from ?

open FILE, "< $filename" or die "Cannot open $filename\n";
@lines = <FILE>;
close FILE;

open FILE, "> $filename" or die "Cannot open $filename to write\n";
foreach $line (@lines) {
  $line =~ s/Einat/Shalom/g;
  print FILE $line;
}
close FILE;

-- Gabor




More information about the Perl mailing list