Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use warnings;
- use strict;
- # get command line
- my $usage = "substitute.pl <infile> <outfile>\n";
- my $infile = shift or die $usage;
- my $outfile = shift or die $usage;
- open my $in, "<", "$infile" or die "Cannot open $infile: $!\n";
- open my $out, ">", "$outfile" or die "Cannot open $outfile: $!\n";
- while ( <$in> ) {
- chomp;
- print $out "$_\n";
- if ($_ =~ m/Anna/) {
- # set $tmp to equal $_ so we can substitute
- my $tmp = $_;
- $tmp =~ s/Anna/Joanna/;
- print $out "$tmp\n";
- }
- }
- close $in;
- close $out;
- exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement