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:
Output:#!/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.
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |