Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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 drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2014-10-02 12:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (56 votes), past polls