in reply to If condition failing..

From the OP:
Is the if condition if ($2 < pathname_versions{$1}{$2} ) valid?

No. It should be "$pathname_versions{$1}{$2}" -- note the "$", which is missing from your code. Without that "sigil", perl has to treat "pathname_version" as a function name, but you can't have "{" after (or as part of) a function name.

From one of the sub-replies:

What is the use of undef here? $pathname_versions{$1}{$2} = undef;

That's just an economical assignment statement; by assigning "undef" as the value of a hash element, no memory is allocated to store the value, but the hash key is made to exist.

How do I do a hash look up for the hash pathname_versions to see if $2(version in the second list) is less than the version in the list 1?

Based on your earlier posts, I assume that each input list could have 2 or more entries with the same path/name and different version numbers, so it's still not clear to me what particular task you are trying to accomplish with your code,

You never have said what your real purpose is for the scripts you're trying to write, and I'm getting the impression that you haven't completely worked that out yet. It's hard to write effective code when you aren't sure what it's supposed to do. Anyway, here's a version that shows how to handle cases that involve comparing version numbers, assuming that list1 might contain several versions for a given path:

... open( IN, $list2 ) or die "$list2: $!"; while (<IN>) { next unless ( m:(.+?)#(\d+)$: ); my ( $p, $v ) = ( $1, $2 ); next unless ( exists( $pathname_versions{$p} )); if ( exists( $pathname_versions{$p}{$v} )) { # get here if we have a full match (path and version) } else { # create a sorted list of version numbers from list1: my @list1versions = sort {$a<=>$b} keys %{$pathname_versions{$ +p}}; if ( $v < $list1versions[0] ) { # list2 version number is lower than _all_ matching list1 +entries } elsif ( $v > $list1versions[-1] ) { # list2 version number is higher than _all_ matching list1 + entries } } }
Note how I use indentation to indicate code block nesting for the "if" conditions. Proper indentation is very important for legibility.