V
Ved
Hi,
I have written a small program.
Things are fine when I am using functions like REVERSE (i.e. line 12).
But, having problem in Reg Exp statement (line 14).
------------------------------------------
#!usr/bin/perl
use strict; use warnings;
open(my $in, "<", "data2.munge") or die "error reading for reading";
open(my $out, ">", "data3.munge") or die "error creating for writting ";
my $rev =0;
while (<$in>) {
chomp;
#my $rev = reverse $_;
####Below line not working##
my $rev =~ s/dog/cat/;
print $out "$rev\n";
}
close $in;
close $out;
___________________________________________________
cat
dog dog
dog
cat
cat
dog dog
dog
cat
cat
dog dog
dog
cat
I have written a small program.
Things are fine when I am using functions like REVERSE (i.e. line 12).
But, having problem in Reg Exp statement (line 14).
------------------------------------------
#!usr/bin/perl
use strict; use warnings;
open(my $in, "<", "data2.munge") or die "error reading for reading";
open(my $out, ">", "data3.munge") or die "error creating for writting ";
my $rev =0;
while (<$in>) {
chomp;
#my $rev = reverse $_;
####Below line not working##
my $rev =~ s/dog/cat/;
print $out "$rev\n";
}
close $in;
close $out;
___________________________________________________
cat
dog dog
dog
cat
cat
dog dog
dog
cat
cat
dog dog
dog
cat