The code you provided works fine (as shown below). What input are you feeding it?

By the way, "anal" is a very poor choice of abbrieviation for "analysis".

%analysis = ( a_key => 'moop:Did you know that Office Image Running?:foobar!', ); 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; print("class\n"); } elsif ($message =~ /Office Image Running/) { $anal_image_flg = $anal_image_flg + 1; print("image\n"); } elsif ($message =~ /Office Channel Not Logged In/) { $anal_channel_flg = $anal_channel_flg + 1; print("channel\n"); } elsif ($message =~ /Telephath Unable To Connect to Office/) { $anal_host_flg = $anal_host_flg + 1; print("host\n"); } elsif ($message =~ /No New Data Was Collected/) { $anal_data_flg = $anal_data_flg + 1; print("data\n"); } else { # print "Program Error 4 - $key $val\n"; print "Program Error 4 - $message\n"; } } } __END__ output ====== Program Error 4 - moop image Program Error 4 - foobar!

In reply to Re: Is My Split Or My Pattern Bad? by ikegami
in thread 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.