in reply to Grep on the values of a hash seems to be failing - Tricky

I did a search for Hash_filenames on this page:

... my %Hash_filenames=(); ... foreach my $filename(keys %Hash_filenames) {

So, that foreach loop will never be entered and the grep you think is failing (in some undisclosed way) will never be reached.

-- Ken

Replies are listed 'Best First'.
Re^2: Grep on the values of a hash seems to be failing - Tricky
by iphone (Beadle) on Nov 02, 2010 at 06:05 UTC

    Ken, why do you think so?I added some debug statements in the for loop and I can see forloop being entered

      Here's the loop with the grep you think is failing as you posted it:

      foreach my $filename(keys %Hash_filenames) { @{ $Hash_filematches{ $filename } } = grep( (/\/\Q$file_name\E#/i + && !/\.plf/), @{ $Hash_filenames{ $filename } });------>this grep se +ems to be failing, }#for loop end

      There's no print statement.

      %Hash_filenames has no keys: the last occurrence set it that way: my %Hash_filenames=();

      There are two other foreach loops in your code: one looks nothing like this; the other says the grep worked.

      I suspect you're getting very frustrated: your post which you almost immediately said to ignore followed by the double posting of this one rather bears that out. Friendly advice: take a break, collect your thoughts then come back to this code when you're feeling refreshed and ready to tackle it again. Been there, done that, know what I'm talking about. :-)

      -- Ken

        :-)I just pasted only a snippet ,not the complete code,anway I updated it for you.you wont see the debug print statement because I tried it now. Back to discussion,it's getting into the for loop,not sure why isn't is grepping,the same grep works in the second code (slightly modified from the first),that's what is baffling me