For every match your are setting array index 0 in one if-clause, index 1 and 2 in another if-clause and index 3,4 and 5 in a third if-clause. Now if for example the first if-clause doesn't match, index 0 will be undef, but the other indexes will have data in it. Same for the second if-clause.

The solution depends on what your script does

if every match needs all 6 data items to be there, you have to restructure your code. If the first 'if' succeeds, any following 'if' should be inside that if and not matching should result in an error message (or in refuting that match)

If incomplete data in a match is normal you could either just use your "if defined" solution or push data onto your array instead of setting it. i.e.

#instead of $one_match_ref->[3] = $1; $one_match_ref->[4] = $2; $one_match_ref->[5] = $3; #use push( @{one_match_ref},$1,$2,$3 );

That way no holes are generated in your arrays


In reply to Re: Error: Use of uninitialized value $item in concatenation (.) or string at... by jethro
in thread Error: Use of uninitialized value $item in concatenation (.) or string at... by jonc

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.