in reply to Re: find & replace a string in perl
in thread find & replace a string in perl
Hi, here is my modified code, i want to place the comment(#) start of that line my input file consist this data eg: testing is requrired see/for/test test/data/istesting my output should be testing is requrired #see/for/test #test/data/istesting But what ever iam trying it is not working, can you help
#!/usr/bin/perl -w use strict; use warnings; my $line = 0; my $file_name = "test.txt"; open(my $fh, '<', $file_name) || die "file could not open $! \n"; while( $line = <$fh>) { if( $line =~ s/\btest\b/^\#/ig ) { print "$line\n"; } } close($fh);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: find & replace a string in perl
by Corion (Patriarch) on Nov 25, 2010 at 09:29 UTC | |
Re^3: find & replace a string in perl
by mertserger (Curate) on Nov 25, 2010 at 10:10 UTC | |
Re^3: find & replace a string in perl
by Marshall (Canon) on Nov 29, 2010 at 02:40 UTC |
In Section
Seekers of Perl Wisdom