So, since the 'code sub-pattern' won't work ( see ikegami's++ above ) in the way you've attempted (and ++ for taking the challenging route), you may wish to reconsider your approach to the climb.

If so, the following -- hidden in the readmore so as not to spoil the challenge you still face -- will work. Note, however, that I have assumed that the list of data returned by

bash-3.1$ weather --weather Newcastle 009: Newcastle Light Rain Late Light Rain Late. Morning Clouds. War +m.

represents a specific label ("Newcastle) followed by a set of possible alternatives

So, without further ado:

#!/usr/bin/perl use warnings; use strict; # 813676 my ($weather, @weather); while ( <DATA> ) { if ( /(Newcastle[\w\s\.]+.*)/ ){ if ( $1 ) { $weather = $1; chomp($weather); push @weather,$weather; } else { print "No Match in $_\n"; } } else { print "\n\tNo data for Newcastle in current element: $_\n"; # next; } } for $weather(@weather) { print $weather . "\n"; } __DATA__ Newcastle Light Rain Late Light Rain Late. Morning Clouds. Warm. Trent Flurries. Low -4 - -2 C. Newcastle1 Light Rain Newcastle2 Light Rain Late. Newcastle3 Morning Clouds. Warm. High 13-17C. Newcastle4 Occasional Brimstone flurries. Possible Earthquakes. Pleasa +nt. 12 - 17 C.
Output:
No data for Newcastle in current element: Trent Flurries. Low +-4 - -2 C. Newcastle Light Rain Late Light Rain Late. Morning Clouds. Warm. Newcastle1 Light Rain Newcastle2 Light Rain Late. Newcastle3 Morning Clouds. Warm. High 13-17C. Newcastle4 Occasional Brimstone flurries. Possible Earthquakes. Pleasa +nt. 12 - 17 C.

In reply to Re: Code Sub-Pattern Error "Panic: top_env" by ww
in thread Code Sub-Pattern Error "Panic: top_env" by urthwrm

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.