in reply to Re^2: grep confusion
in thread grep confusion

See update, I can't test on my tablet

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re^4: grep confusion
by PriNet (Monk) on Sep 01, 2017 at 02:19 UTC
    'Experimental keys on scalar is now forbidden'
    Let me see if I can add the %{...} and fix that...

    I tried re-inventing the wheel again, but everytime I push it, it still falls flat on it's side...
      Interesting, I came closer by using
      grep { %{$DetailSheet{ColumnName}{$_}{XlsColumn}} == 2 } keys %{$Detai +lSheet{ColumnName}}

      but i got 'can't use string ("-1") as a HASH reference' error, to which, i do use XlsColumn => -1 on the key/values that i don't use in the full 'DetailSheet' hash...

      I tried re-inventing the wheel again, but everytime I push it, it still falls flat on it's side...
        You are probably missing a comma in your "unused' key.

        This works:

        DESCRIPTION => { .... }, UNUSED => {XlsColumn => -1} } );
        My print statement works without complaint:
        print grep ({ $DetailSheet{ColumnName}{$_}{XlsColumn} == 2 } keys %{ +$DetailSheet{ColumnName}} ) ,"\n"; # Note - grep params are enclosed in parens.

                        All power corrupts, but we need electricity.

        I've tried several variations of the grep suggested and either get strict errors or 'arbitrary' values from other values in the hash, I may have to resort to a for loop with an flat array using the XlsColumn values as the array indexes. thanx for the idea though, I'm always looking for shortcuts and I hoped grep would help.

        I tried re-inventing the wheel again, but everytime I push it, it still falls flat on it's side...