http://www.perlmonks.org?node_id=1231784

kaushik9918 has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I have a text file containing different file names ex :

/fd/gfree/tere/frf4545/geerg/fds/0.1/fsdf/dsakdsa/

/fd/gfree/tere/frf4545/geerg/dfds/5.9/fdsf/fdsfd/

/fd/gfree/tere/frf4545/geerg/dsad/02.44/fdsf/fdsf/

...

...

I want to remove the patterns appearing after the decimal numbers. So my output text file should have

/fd/gfree/tere//frf4545/geerg//fds/0.1

/fd/gfree/tere//frf4545/geerg//dfds/5.9

/fd/gfree/tere//frf4545/geerg//fds/02.44

...

...

I have tried the following code, but doesnt seem to work. Can anyone help me with shortest code to do this inside a perl subroutine? Pardon my beginner level question at perl coding.

if($line=~ /^\/fd\/gfree\/tere\/frf4545\/geerg\/(.*)\/(.*)\/fsdf\/(.*) +\//){ + + $line=~ s/\/fsdf\(.*)\///g; + }

regards