in reply to Re: File pairing from different directories
in thread File pairing from different directories

Humble Mönch,

Thanks for a detailed explanation and quite useful pointers. To be honest , I never realized so much stuff is already there in perlfaq for which I keep wasting my time googling around.

I have a doubt..When you say "canonicalize the names to a common form" ,Does it mean that determining a pattern that would be used to identify the file names from the array. If so then I am already doing that

my $patt=substr($_,0,index($_,"xml"));
and then I grep this pattern in the other array. From the code in perlfaq, I get to know @difference, union of both arrays and intersection between the two arrays. If I have to pair up the values from alpha and gamma like hash{abc_12342_tick.xml.alphaprod} = abc_12342_tick.xml.gammaprod , I still will have to grep for the pattern in any one of the arrays.

Hope I am not badly missing something here

Replies are listed 'Best First'.
Re^3: File pairing from different directories
by Corion (Patriarch) on Sep 08, 2009 at 13:35 UTC

    By "canonicalize the names to a common form", I mean to convert the names into a common form, throwing away all the parts that identify the environment the files came from. In your case, that means throwing away at least .alphaprod and .gammaprod. Your substring approach does that (and a bit more) - it will throw away xml.alphaprod and xml.gammaprod, which should be OK for your purpose.

    You don't need to use grep, which will look at every element in the other list. By putting each list into a separate hash (I usually call them %left and %right, and mean to have the elements on the left side of the comparison in %left), you allow Perl to skip looking through all elements and to directly see whether an element exists.