hello,
im having a problem to change a particular word in a line, canīt find where is my mistake
also i would like to know how to make this program check automatically if a particular word exists on the line you got to you exchange it or not
i didnt find the right condition to do it
-
-
#!C:/perl/bin/perl.exe #Handle Area - in - outfile
-
-
start: open my $file, q{c:/perl/discoverEdit[1].4796.11.30.5.8.2009.dci} or die "Can't open input file";
-
-
open(OUTFILE, "> c:/perl/report.dci") or die "Can't open output file";
-
-
my @read = <$file>;
-
print "This file has: " .scalar(@read) . " lines\n";
-
-
print "which line you want to get?\n";
-
-
chomp (my $match = <STDIN>);
-
-
print $read[$match];
-
-
foreach($match) { print "$_\n"; }
-
-
print "exchanging word\n";
-
-
print "which word need exchange\?\n";
-
-
$let=<STDIN>; chomp $let;
-
-
print "change $let for...\n";
-
-
$new=<STDIN>; chomp $new;
-
-
if($new eq $let) { print "the word cannot be matched \n"; sleep 2; goto start;}
-
-
else { print "starting exchange...\n\n";
-
-
foreach ($match) { s/$let/$new/g; print "$_\n"; }
-
-
print "\n backing to..\nto exit ctrl+c\n\n"; sleep 5; goto start; }
-
-
Thank You