in reply to Re^2: If condition failing..
in thread If condition failing..

I didn't follow the discussion in the original thread, so maybe I'm missing something... but why don't you store the version as the value of the hash entries?

while (<IN>) { # first list next unless ( m:(.+?)#(\d+)$: ); $pathname_versions{$1} = $2; }

In this case you could later simply do (where $pathname_versions{$1} retrieves the corresponding version from the first list)

while (<IN>) { # second list next unless ( m:(.+?)#(\d+)$: ); ... if ( $pathname_versions{$1} < $2 ) { ...

Replies are listed 'Best First'.
Re^4: If condition failing..
by perl_mystery (Beadle) on Dec 13, 2010 at 01:49 UTC

    Actually I want the other way like below,but if i use it i am getting the below error.

    if ( $pathname_versions{$1} > $2) { #if the version in list2 i +s less than version for the same path in list1 print "IN\n"; }

    Can't use string ("6") as a HASH ref while "strict refs" in use at orphan_overwrite.pl line 30, <IN> line 28

      Can't use string ("6") as a HASH ref

      This is probably because somewhere else you still have $pathname_versions{$1}{$2}.

      So, if $pathname_versions{$1} is now "6", for example, the {$2} would be trying to dereference the value "6", i.e. "6"->{$2}, which doesn't make much sense...