in reply to If condition failing..

Re^4: Comparing the filepaths and versions in two hashes

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

    1.What is the use of undef here?

    $pathname_versions{$1}{$2} = undef;

    2.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?

      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 ) { ...

        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