in reply to Code Sub-Pattern Error "Panic: top_env"

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.

Replies are listed 'Best First'.
Re^2: Code Sub-Pattern Error "Panic: top_env"
by urthwrm (Novice) on Dec 29, 2009 at 01:27 UTC
    Sorry for the delay, I've been busy with university. I appreciate all the reply's, i have learned a lot. Anyway, i ended up taking the easy way out just to get things working. Here's my code for who ever might be interested!
    #!/usr/bin/perl -w use strict; while(<>) { if(m/\s*\ \w+ \ (\w+| \w+\ \w+| \w+\ \w+\ \w+) \ (?=\1)/x) { $_ =~ s/$1//; print; } }