Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: Collapsing a list of files...

by graff (Chancellor)
on Sep 17, 2009 at 03:53 UTC ( #795761=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Collapsing a list of files...
in thread Collapsing a list of files...

Hopefully this helps!

Not entirely, perhaps...

... a suffix of n digits. Now that I think about it, you can ignore the suffix altogether and just replace the n digits with *.

Well, I'm assuming there must be some other constraint (which you haven't described yet) that would make this an inadequate solution:

my %collapsed; opendir( D, "/whatever/path" ) or die "whatever: $!\n"; for my $name ( grep /\d+$/, readdir D ) { $name =~ s/\d+$/*/; $collapsed{$name}++; } for my $name ( sort keys %collapsed ) { print "$name\n"; }
If you're trying to do something else besides ignoring the final digits -- if there's supposed to be some actual structure to the file names and you need to do something with that besides adding "*" at the end -- let us in on it. From what you've described so far, it's either too simple or too vague.


Comment on Re^3: Collapsing a list of files...
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2014-09-02 06:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (20 votes), past polls