bash-3.1$ weather --weather Newcastle
009: Newcastle Light Rain Late Light Rain Late. Morning Clouds. Warm.
####
#!/usr/bin/perl
use warnings;
use strict;
# 813676
my ($weather, @weather);
while ( ) {
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. Pleasant. 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. Pleasant. 12 - 17 C.