As far as I am able to tell, the warning is being generated in the grep. Splitting it in to seperate lines in the code said that the warning was in the second occurence of @{$bros->{$yr}} - the array being grepped.

The code I'm using to initialize the whole structure is:

my $bros= {'1958' => [], '1959' => [], '1960' => [], '1961' => [], '1962' => [], '1963' => [], '1964' => []};

since I was lazy and wanted to pre-build my data structure.

Here's the Data::Dumper listing of before and after the grep:

before grep: $VAR1 = \[ { 'state' => 'OR', 'last' => 'Bertelson', 'first' => 'Gordon', }, { 'state' => '', 'last' => 'Blaise', 'first' => 'Larry', }, { 'state' => 'OR', 'last' => 'Douda', 'first' => 'Henry B.', }, { 'state' => 'NSW 221', ' => 'Australia', 'last' => 'McHolick', 'first' => 'Dwane', }, { 'state' => 'OR', 'last' => 'Murray', 'first' => 'Melvin', }, { 'state' => 'OR', 'last' => 'Perry', 'first' => 'Larry', }, { 'state' => '', 'last' => 'Peterson', 'first' => 'Ken', }, { 'state' => 'OR', 'last' => 'Rianda', 'first' => 'Dave', }, { 'state' => 'OR', 'last' => 'Steffanoff', 'first' => 'Nick', }, { 'state' => 'CA', 'last' => 'Turner', 'first' => 'Paul', }, { 'state' => 'OR', 'last' => 'Wilson', 'first' => 'Dick', }, {} ]; after grep: $VAR1 = \[ { 'state' => 'OR', 'last' => 'Bertelson', 'first' => 'Gordon', }, { 'state' => '', 'last' => 'Blaise', 'first' => 'Larry', }, { 'state' => 'OR', 'last' => 'Douda', 'first' => 'Henry B.', }, { 'state' => 'NSW 221', 'last' => 'McHolick', 'first' => 'Dwane', }, { 'state' => 'OR', 'last' => 'Murray', 'first' => 'Melvin', }, { 'state' => 'OR', 'last' => 'Perry', 'first' => 'Larry', }, { 'state' => '', 'last' => 'Peterson', 'first' => 'Ken', }, { 'state' => 'OR', 'last' => 'Rianda', 'first' => 'Dave', }, { 'state' => 'OR', 'last' => 'Steffanoff', 'first' => 'Nick', }, { 'state' => 'OR', 'last' => 'Wilson', 'first' => 'Dick', }, {} <- here's the empty hash ];

so you can see exactly what I'm saying by there's an empty hash where Paul Turner's information was.

As far as removing the element, I thought using the negative grep would find everything that didn't match what I wanted and put it in the array. I thought I was on the right track with the negative grep but I don't understand the empty hash in the array still being there.

My assumption is that grep is choking for whatever reason on that empty hash, so is a negative grep the way to go here?

Useless trivia: In the 2004 Las Vegas phone book there are approximately 28 pages of ads for massage, but almost 200 for lawyers.

In reply to Re^2: Using grep to remove array element from HoAoH leaving empty array-hash element by Popcorn Dave
in thread Using grep to remove array element from HoAoH leaving empty array-hash element by Popcorn Dave

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.