This code is for anyone who stays in their room all day, and never goes outside. If you are completely oblivious, this script will serve you well because you will never again wonder if you have been in an earthquake or not. Basically, it is incredibly simple and useless (please don't hurt me, I'm new), but it serves a useless purpose...which is a Good Thing sometimes. It uses the "quake" account at at some USGS site that , when fingered, returns all of the recent earthquakes in the world. It takes as an argument, either the magnitude or the location of said earthquakes. Thank you Uncle Sam!
#!/usr/bin/perl -w if ($ARGV[0]) { $arg = $ARGV[0]; $arg =~ tr/a-z/A-Z/; $result = `finger quake\ | grep "$arg"`; print $result if $result ne undef; } else { $result = `finger quake\ | tail -27`; print $result if $result ne undef; }


Replies are listed 'Best First'.
RE: Oblivious?
by jlp (Friar) on Jul 03, 2000 at 03:24 UTC
    Instead of using tr///, why not use uc()?

    $arg = uc $arg;

      Because I was previously unaware of the fact that uc would serve this purpose better. Now I know, and knowing is half the battle. THanks for the tip.

(jcwren) RE: Oblivious?
by jcwren (Prior) on Jun 21, 2000 at 17:04 UTC
    I vote this ++ simply because it helps avoid leaving the keyboard to check for such things.

    More XP if you can come up with scripts for tornadoes within 50 miles of my location, polar ice cap melting, impending meteor strikes, and hordes of locusts.

      Another good thing is get a weather report from your local airport (METAR format, there is a module on CPAN to help with the decoding), this can save a lot of wasted time looking out of the window etc.
        To that effect I submit the following:
        Requires: Geo::METAR
        #!/usr/bin/perl -w # Gets METAR information from my Favorite Airports and # displays temp and wind speed direction. use LWP::UserAgent; use Geo::METAR; use strict; my $ua = LWP::UserAgent->new; my $uri = ""; my $m = new Geo::METAR; #airport codes my %code = ( Renton => 'krnt', Ephrata => 'keph', Boeing_Field => 'kbfi', CourDAlene => 'kcoe', Sea_Tac => 'ksea', ); my (%site,$key,$value); while (($key,$value) = each %code) { $site{$value}=$key; } for (keys %code) { $uri .= $code{$_} . "%20"; } my $req = HTTP::Request->new('GET',$uri); my $res = $ua->request($req); if ($res->is_success) { my @content = split("\n",$res->content); if (@content) { for (@content) { if (/\d{6}Z/) { $m->metar($_); print <<"EOT"; Site: $site{lc($m->{SITE})} Time: $m->{TIME} Temp: $m->{F_TEMP} deg F. Wind: $m->{WIND_MPH} mph. Dir: $m->{WIND_DIR_ENG} EOT } } } } else { print "Error: " . $res->status_line . "\n"; }

        Update: Per Odud's excellent suggestion, I added error checking on the get. This meant usingLWP::UserAgent rather than LWP::Simple

RE: Oblivious?
by Adam (Vicar) on Jun 23, 2000 at 01:17 UTC
    This is great! I live in So.Cal. and sometimes I can't tell if the air conditioner just kicked on or if we had a minor (3.0 or less) earthquake. They feel the same. And since I've been through several earthquakes my first reaction is always something like: Earthquake? Get under desk? No, just truck going by outside. Ok.
      My pleasure. I think I just might make it my purpose here at PM to code completely useless (or in your case, almost useless) programs for my fellow PMers that are, despite their impractical nature and purpose, highly amusing.
(zdog) RE: Oblivious?
by zdog (Priest) on Jun 26, 2000 at 10:31 UTC
    I love the idea for the script. Very creative. But for me at least, unless the ceiling is falling down on me, I don't really care if there was an earthquake. Heh-heh. Nonetheless, it is a very cool script and you deserve a pat on the back.

    -- zdog (Zenon Zabinski)
       Go Bells!! ''