in reply to Renaming a group of files by referring to a list

If I understand your problem correctly (my reading is: You have a list of files, you have a list of old/new filename pairs, you want to know which files have a corresponding new filename) then this problem just screams HASH.

A hash lets you index the elements by a string, so rather than searching an array (via List::Compare) for the matching element, you can write things like:

%rename_hash = ( 'oldname' => 'newname' ); if( exists $rename_hash{ $filename } ) # Does this file get changed? { ... } $newname = $rename_hash{ $filename } # What's the new name? ...
You might even be able to squeeze all the code into File::Find::find()'s \&wanted parameter (though risky as you'd be changing the data File::Find is looking through).

Replies are listed 'Best First'.
Re^2: Renaming a group of files by referring to a list
by squirell (Initiate) on Dec 11, 2007 at 02:34 UTC
    I forgot about Hashes! I'll go re-read that chapter for tonight, thanks!