Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Files in a directory

by choroba (Abbot)
on Apr 28, 2013 at 10:42 UTC ( #1031051=note: print w/ replies, xml ) Need Help??


in reply to Files in a directory

Use split:

#!/usr/bin/perl use warnings; use strict; use feature qw(say); my $filename = 'p_abc_xyz_123.txt'; my ($basename, $suffix) = split /\./, $filename; my @parts = split /_/, $basename; for my $i (1 .. $#parts) { say join('_', @parts[0 .. $i]), ".$suffix"; }
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: Files in a directory
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2014-12-28 23:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (183 votes), past polls