Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: Pattern replace in a file name

by hippo (Bishop)
on Mar 28, 2019 at 09:47 UTC ( #1231793=note: print w/replies, xml ) Need Help??


in reply to Re^2: Pattern replace in a file name
in thread Pattern replace in a file name

Now that your expected output looks more logical, a simple test can illustrate one possible solution.

use strict; use warnings; use Test::More; my @data = ( { have => '/fd/gfree/tere/frf4545/geerg/fds/0.1/fsdf/dsakdsa/', want => '/fd/gfree/tere/frf4545/geerg/fds/0.1', }, { have => '/fd/gfree/tere/frf4545/geerg/dfds/5.9/fdsf/fdsfd/', want => '/fd/gfree/tere/frf4545/geerg/dfds/5.9', }, { have => '/fd/gfree/tere/frf4545/geerg/dsad/02.44/fdsf/fdsf/', want => '/fd/gfree/tere/frf4545/geerg/dsad/02.44', }, ); plan tests => scalar @data; for my $t (@data) { $t->{have} =~ s/(\.\d+).*?$/$1/; is $t->{have}, $t->{want}; }

Replies are listed 'Best First'.
Re^4: Pattern replace in a file name
by kaushik9918 (Sexton) on Mar 28, 2019 at 09:52 UTC

    Perfect! Thanks for your time. Your solution works perfectly for me.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1231793]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2022-09-27 18:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (123 votes). Check out past polls.

    Notices?