hi to all and thanks to all suggested me some solution,
using debug lines (or something similar) I understood how obtaining the
output I want.
Now, I'm writing this e-mail to show a possible way to do a discrete
corrector: I write a regexp to substitute (maybe with another regexp
including backreferences too), and it shows me each match so I can
decide if I want to correct or not.
This solution is quite trivial and rude, but it works:
#!/usr/bin/perl -w
my ($choice, $s1,$s2,$s3,$s4);
$^I ='_old';
print "pattern: ";
$pattern = <STDIN>;
chomp($pattern);
print "replacement: ";
$replacement = <STDIN>;
chomp($replacement);
print "\n print \"s\" to confirm substitution; print \"n\" to avoid it
print \"n\" \n\n";
while(<>)
{
$choice = "";
if(/$pattern/gi)
{
print STDOUT "\n\nmatch!:\n\t \$1 = $1\n\t pattern: $pattern\n";
$s1 = $1;
$s2 = $2;
$s3 = $3;
$s4 = $4;
$replacement =~ s/\$1/$s1/g;
$replacement =~ s/\$2/$s2/g;
$replacement =~ s/\$3/$s3/g;
$replacement =~ s/\$4/$s4/g;
print STDOUT "\t replacement: $replacement\n"
print STDOUT "I'd subsitute this one => ". $_."\n\n";
$choice = <STDIN>;
chomp($choice);
}
s/$pattern/$replacement/gi if $choice eq "s";
print;
}
thank you all,
alladr
|^|_|^|_|^| |^|_|^|_|^|
| | | |
| | | |
| |*\_/*\_/*\_/*\_/*\_/* | |
| |
| |
| |
| http://www.e-allora.net |
| |
| |
**************************************
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>