in reply to Re: Removing dots
in thread Removing dots

ok let's say if i want it to look like Hello.1txt would s/\.(?=txt$)//g do the job?

Replies are listed 'Best First'.
Re^3: Removing dots
by tlm (Prior) on May 08, 2005 at 15:17 UTC

    You can get your answer more quickly by firing up the debugger and just trying it out:

    % perl -de 1 DB<1> $s = 'Hello.1.txt' DB<2> $s =~ s/\.(?=txt$)//g # in this case the /g is superfluous DB<3> p $s Hello.1txt
    And faster still (in the long run) if you just study perlre.

    the lowliest monk

Re^3: Removing dots
by eibwen (Friar) on May 08, 2005 at 19:38 UTC

    If you really want to remove all but the first occurance:

    $filename =~ /\./; substr($filename, $-[0]+1) =~ s/\.//g if @-;