Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Files in a directory

by choroba (Chancellor)
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"; }
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031051]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2016-12-10 04:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (159 votes). Check out past polls.