Todd Wade wrote: > > This sub grabs http://weather.noaa.gov/pub/data/forecasts/zone/oh/ohz021.txt > with LWP::Simple, extracts the current weather conditions out of the heading > and future forecast, Lowercases the entire string, uppercases the first word > in every sentence, and returns the string. > > sub current_weather_conditions { > my($weather) = > get('http://weather.noaa.gov/pub/data/forecasts/zone/oh/ohz021.txt'); > ($weather) or return('Today\'s weather conditions are currently > unavailable'); > $weather =~ s/.*?\n\.[^.]*?\.{3}(.*?)\n\..*/$1/s;
Why remove everything you don't want, why not just capture the data you do want? > $weather =~ tr/[A-Z]\n/[a-z] /; ^ ^ ^ ^ Why are you translating a '[' to '[' and ']' to ']'? Why are you translating "\n" to " " when there are no newlines in $weather? > $weather =~ s/( ?)(.)(.*?)\./$1\U$2\E$3\./g; > return($weather); > } my $url = 'http://weather.noaa.gov/pub/data/forecasts/zone/oh/ohz021.txt'; sub current_weather_conditions { my $weather = lc $1 if get( $url ) =~ /^\.[^.]*?\.{3}(.*)$\./m; return q(Today's weather conditions are currently unavailable) unless length $weather; $weather =~ s/(\w+)/\u$1/g; return $weather; } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]