John W. Krahn wrote:

> Todd Wade wrote:
> 
> Why remove everything you don't want, why not just capture the data you
> do want?

sure....

> 
>>  $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?

Youre right about part a, but not part b. There (usually) are newlines in 
$weather. Look at the document:

http://weather.noaa.gov/pub/data/forecasts/zone/oh/ohz021.txt

>     $weather =~ s/(\w+)/\u$1/g;

This assumes any non alphanumeric character denotes a sentence boundary.  

#!/usr/local/bin/perl

print change("there's more than one way to do it."), "\n";

sub change {

  $str = shift();
  $str =~ s/(\w+)/\u$1/g;
  return( $str );

}

__END__

[trwww@misa trwww]$ perl str.pl
There'S More Than One Way To Do It.
      ^ ^    ^    ^   ^   ^  ^  ^

The topic seemed to do with capitalizing the first letter in each sentence. 
It was interesting because it was one of the first working regexes I wrote, 
so I posted my code. That sub is probably the sub that sold me on perl =0). 
Dynamic weather report in 5 lines of code!!??!! Sweet.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to