Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

grantm (164)

grantm
  (email not shown publicly)
http://www.mclean.net.nz/

Just a simple [cpan.org] guy, hacking Perl for fun and profit since way back in the last millenium. You may find me hanging around in the monestary [perlmonks.org].

What am I working on right now? Probably the Sprog project [sourceforge.net].

GnuPG key Fingerprint:
6CA8 2022 5006 70E9 2D66
AE3F 1AF1 A20A 4CC0 0851

Journal of grantm (164)

Tuesday June 20, 2006
07:53 PM

Silly time waster

[ #29982 ]

perl -nle '/(.*?)(us)$/ && print "http://$1.$2"' /usr/share/dict/words

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • This works on my Mac (change "/usr/bin/open" to the right command on your system). It searches the dictionary for words ending in "us". It picks a random one from that list, checks if it's a valid web host, and opens a browser tab to that site. Everytime it finds a host, it sleeps for 15 minutes to give you time to enjoy the site.

    My first find was http://zygomatic.us/ [zygomatic.us]

    #!perl -w
    use strict;
    use Socket;
    use LWP::Simple qw(head);
    $| = 1;
    open my $fh, ';
    close $fh;
    print "Found ".@words." candidates\n";
    while (@words
    • Uhh, sorry, slashcode ate my open() command. Take 2:


      #!perl -w
      use strict;
      use Socket;
      use LWP::Simple qw(head);
      $| = 1;
      open my $fh, '<', '/usr/share/dict/words';
      my @words = grep {/us$/m} ;
      close $fh;
      print "Found ".@words." candidates\n";
      while (@words > 0) {
            my $word = splice @words, int(rand scalar @words), 1;
            (my $host = $word) =~ s/us\s*\z/.us/s;
            print '.';
            next if (!inet_aton($host));
            my $url = "http