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

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.

  •     my $i = 1;
        my %month = map { $_ => $i++ } qw/jan ... dec/;


    Hmmm. How about:


        my %month;
        @month{ qw/jan ... dec/ } = 1..12;


    And also:


        DOMAIN: while (<DATA>) {
            chomp;
            next if /^\s*$/;
            my @whois = `whois $_`;
            LINE: foreach my $line (@whois) {
                if ($line =~ /expire/i) {
                    my $date;
                    if ($line =~ /.../) {
                        $date = join '-', $1, ...;
                    } elsif ($line =~ /.../) {
                        $date = join '-', reverse, ...;
                    }
                    if ($date) {
                        $domain{$_} = $date;
                        next DOMAIN;
                    }
                }
            }
            printf "Error: ...\n", $_;
        }


    Whew! How about:


        for my $domain ( grep /\S/, <DATA> ) {
            chomp $domain;
            for ( grep /expire/i, `whois $domain` ) {
                if ( /.../ ) {
                    $domain{$domain} = join '-', $1, ...;
                    last;
                }
                if ( /.../ ) {
                    $domain{$domain} = join '-', reverse, ...;
                    last;
                }
            }
            printf "Error: ...\n", $domain;
        }


    Well, it's JAWTDI.