Here is a code snippet that I wrote for this procedure but for some reason the source 
file seems to disappear on files with 4000+ lines.  Just trying to isolate the 
problem. Does anyone recommend a better way for this procedure?

open(SOURCE, "< $SOURCEFILE")
        or die "\n***** Could not open specified source file $SOURCEFILE: $!\n";
my $TEMPFILE=$SOURCEFILE . '_tmp';

open(TEMP, "> $TEMPFILE") or die "Could not open tempfile $TEMPFILE: $!";

while (<SOURCE>) {
       unless ($. == 1) {
              (print TEMP $_) or die "\n***** Could not write to tempfile $TEMPFILE: 
$!";
       }
}

close(SOURCE) or die "Can't close source file $SOURCEFILE: $!";
close(TEMP) or die "Can't close tempile $TEMPFILE: $!";

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 novice (going crazy)

i cant seem to find the sequence to substitute all "." with "_" EXCEPT for
the last one


ex. change abc.def.ghi.jkl.mno
    to     abc_def_ghi_jkl_.mno

any help or pointers please?
thank you
mario

_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to