I don't understand why the code always hits the "else" statement. The below sample output implies that the pattern and the spilt worked "ok" so could you please point out my error?
foreach $key (keys %analysis) { @msg = (); $val = $analysis{$key}; @msg = split /:/, $val; $anal_host_flg = 0, $anal_data_flg = 0, $anal_entries = 0; $anal_class_flg = 0, $anal_image_flg = 0, $anal_channel_flg = 0; foreach $message (@msg) { print "$message\n"; $anal_entries = $#msg + 1; if ($anal_entries == 0) { print "Program Error 3 - $key $val\n"; } if ($message =~ /SECTION IS NOT IN EADAS CLASS/) { $anal_class_flg = $anal_class_flg + 1; } elsif ($message =~ /Office Image Running/) { $anal_image_flg = $anal_image_flg + 1; } elsif ($message =~ /Office Channel Not Logged In/) { $anal_channel_flg = $anal_channel_flg + 1; } elsif ($message =~ /Telephath Unable To Connect to Office/) { $anal_host_flg = $anal_host_flg + 1; } elsif ($message =~ /No New Data Was Collected/) { $anal_data_flg = $anal_data_flg + 1; } else { print "Program Error 4 - $key $val\n"; } } }
Sample output is below. Please note the value for $key was removed. Program Error 4 - <$key> :Office Channel Not Logged In :No New Data Was Co Office Channel Not Logged In No New Data Was Collected Program Error 4 - <$key> :SECTION IS NOT IN EADAS CLASS :SECTION IS NOT IN SECTION IS NOT IN EADAS CLASS SECTION IS NOT IN EADAS CLASS

In reply to Is My Split Or My Pattern Bad? by tc1364

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.