#!/bin/bash OUT="$HOME/.weatherbot-chatter" while true;do lynx -dump http://www.w3.weather.com/weather/local/USOR0275? | sed -n '/Current Conditions for Portland, OR/,$p' | head -n15 | perl -e ' sub fisher_yates { my $i = @_; while( $i-- ) { my $j = int rand( 1 + $i ); @_[$i,$j] = @_[$j, $i]; } } my ($hot, $cold, $vis, $wind, $rain)=(-1000, 1000); while (<>) { if(/([0-9]+)°F/) { $cold = $1 if $1 < $cold; $hot = $1 if $1 > $hot; } if(/Rain/) { $rain = true; } if(/Visibility:\s*([0-9.]+)/) { $vis = $1; } if(/Wind:/) { tr/0-9 //cd; $wind = (sort(split()))[-1]; } } @conditions=qw(hot cold vis wind rain); fisher_yates(@conditions); for(@conditions) { if(/hot/ and $hot > 90) { print "Boy, it'\''s hot!"; last; } if(/cold/ and $cold < 30) { print "Brrr, it'\''s cold!"; last; } if(/vis/ and $vis < 0.3) { print "It'\''s foggy!"; last; } if(/wind/ and $wind > 40) { print "It'\''s windy!"; last; } if(/rain/ and $rain) { print "It'\''s raining!"; last; } } print "\n"; ' >> "$OUT" sleep $RANDOM done