#!/usr/bin/perl -w
# use strict;
sub replace_str($$$)
{
my $line = shift;
my $old_string = shift;
my $new_string = shift;
if($line =~ m/($old_string)/)
{
$line =~ s/$old_string/$new_string/;
}
return $line;
}
open (SOURCE_FILE, "source.txt");
open (DESTINATION_FILE, '>>destination.txt');
while ($line = <source_file>) {
$line = replace_str($line,"2","3");
print DESTINATION_FILE $line;
}
close(SOURCE_FILE);
close (DESTINATION_FILE);
Sep 14, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment