in reply to grep confusion

#!/usr/bin/perl -l # http://perlmonks.org/?node_id=1198481 use strict; use warnings; my %DetailSheet = ( 'ColumnName' => { 'ID' => { 'PositionAdjustment' => 0, 'RecordName' => 'Identification', 'RecordNumber' => 0, 'RecordValue' => '', 'XlsName' => 'Reference', 'XlsColumn' => 1, 'XlsFormat' => '', 'XlsWidth' => 15, 'XlsLock' => 1, 'GuiName' => 'Number', 'GuiNumber' => 2, 'GuiValue' => '', 'Switch' => [ ['O','0'], ['l','1'] ] }, 'DESCRIPTION' => { 'PositionAdjustment' => 0, 'RecordName' => 'Description', 'RecordNumber' => 1, 'RecordValue' => '', 'XlsName' => 'Description', 'XlsColumn' => 2, 'XlsFormat' => '', 'XlsWidth' => 15, 'XlsLock' => 1, 'GuiName' => 'Description', 'GuiNumber' => 3, 'GuiValue' => '', 'Switch' => [ [' AND ', ' & '], [' WITH ', ' W/ '] ] } } ); print grep { $DetailSheet{ColumnName}{$_}{XlsColumn} == 2 } keys %{ $DetailSheet{ColumnName} };

Outputs:

DESCRIPTION

Replies are listed 'Best First'.
Re^2: grep confusion
by PriNet (Monk) on Sep 01, 2017 at 04:00 UTC
    Ok, I'm not sure what happend, but I used your reference tybalt89 and I think I got the result I was after... grep does work! thanx a gigabyte, I'm going to continue with my program now (it kinda got more complicated than I thought when I started the project)... thanx again guys, given the time and enough twinkies, you guys have come through for me again...
    -Gary

    I tried re-inventing the wheel again, but everytime I push it, it still falls flat on it's side...
      tybalt89 's and my solution are identical as far as I see.

      The only difference is he included the provided data in his example, and you are most probably running my code against broken data.

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

        I caught that LanX, I didn't mean to leave you out of the credits, sorry, everyone here (when I can catch em) help me alot in my ventures, I didn't forget to give the both of you ++ votes though! I think part of my issues here are that I'm running perl in an oracle virtualbox (to protect my main system) and I get arbitrary errors once in a while, my latest 'sometimes' error (which I'm investigating right now) is 'Modification of non-creatable array value attempted' (that just started on a previously fine, executable line before) is starting to get annoying, quite possibly because my script may not have enough memory available, it's up to about 1300 lines @ 52k and the irronious errors are showing up more and more, I'll email you an extra twinkie Lanx, thanx to everyone again...

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