F
fred
I have some code created to takes some rules from external file and
apply these rules on text file. My perl experience is somewhat limited
and I was wondering if soneone on this group can give me an
explanation of it.
sub apply_rules {
my ($_txt, $_rules) = @_;
for (keys %{$_rules}) {
my $exp = $_;
$exp =~ s{\s}{\\s*}g;
my $re = $_rules->{$_};
my $rslt;
eval ("\$rslt = \$\$_txt =~ s{$exp}{$re}gis");
printf " >Replaced '$exp' %d times.\n", $rslt;
}
}
apply these rules on text file. My perl experience is somewhat limited
and I was wondering if soneone on this group can give me an
explanation of it.
sub apply_rules {
my ($_txt, $_rules) = @_;
for (keys %{$_rules}) {
my $exp = $_;
$exp =~ s{\s}{\\s*}g;
my $re = $_rules->{$_};
my $rslt;
eval ("\$rslt = \$\$_txt =~ s{$exp}{$re}gis");
printf " >Replaced '$exp' %d times.\n", $rslt;
}
}