Mario,
Sure there is a better way, but
with
s/(\w+)\./$1_/g # All dots to underscores
you get
abc_def_ghi_jkl_mno
then, with
s/_(\w[^_]+)$/_\.$1/ # the last underscore to "_."
you get
abc_def_ghi_jkl_.mno
Antonio
El 27-may-04, a las 13:49, mario sanchez escribió:
help for a nov
Mario,
This will do what you're wanting:
1. #!/usr/bin/perl
2.
3. $string = "abc.def.ghi.jkl";
4. print "pre-sub: $string\n";
5.
6. $string =~ s/\./_/g;
7.
8. print "post-sub: $string\n";
Note line 6 is what actually does the substitution. You have to escape the
period because Perl will think
It's not pretty or elegant but it does get the job done:
$str = "abc.def.ghi.jkl.mno";
@parts = split /\./, $str;
for ($i=0; $i<$#parts; $i++) {
$new_str .= "$parts[$i]_"; }
$new_str .= ".$parts[-1]";
Matthew Schneider
System Administrator / Programmer
SKLD Information Services, LLC
303.820.0