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

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

Replies are listed 'Best First'.
Re^6: grep confusion
by NetWallah (Canon) on Sep 01, 2017 at 03:27 UTC
    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.

Re^6: grep confusion
by PriNet (Monk) on Sep 01, 2017 at 03:18 UTC
    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...