a really poor excuse for a Perl script.

version 0.1: pulls down my home node, does some stupid stuff to get to the "write ups/experience" line, strips away the html and the number of write ups from the next line, and all that remains is my current amount of experience.

(and yeah yeah I know about the whole e2 as a MUD, XP whore thing .. I was just bored and Perl is cool)

#!/usr/bin/perl
#
# pull down my current exp on e2.
#
# - ithron (25. May 2000)

@homenode = `lynx -source http://everything2.com/index.pl?node_id=425857`;

foreach (@homenode) {
    chop;
    if ($f == 1) {
        $_ =~ s/\<.+?\>//g;
        $_ =~ s/\d+\///;
        print $_ . "\n";
        exit;
    }
    if ($_ =~ /experience/) { $f = 1 }
}

# eop.


version 0.2: does basically the same thing as version one except it now gets the experience and number of nodes, prints both of those out, and then computes and prints the experience to nodes ratio.

#!/usr/bin/perl
#
# v1: pull down my current exp on e2 - ithron (25. May 2000)
# v2: show exp to nodes ratio - ithron (28. May 2000)

@homenode = `lynx -source http://everything2.com/index.pl?node_id=425857`;

foreach (@homenode) {
    chop;
    if ($f == 1) { 
        $_ =~ s/\<.+?\>//g;
        ($num, $exp) = split(/\//, $_);
        last;
    }
    if ($_ =~ /experience/) { $f = 1 }
}

print "\n    nodes: $num\n";
print "      exp: $exp\n";
print "exp/nodes: " . substr($exp/$num, 0, 3) . "\n\n";

# eop.


version 0.3: does everything version 2 does except one can now look at any e2 user's exp, etc. ... also threw in "use strict;" and "-w" for respectability.

#!/usr/bin/perl -w
#
# v1: pull down my current exp on e2 - ithron (25. May 2000)
# v2: show exp to node ratio - (28. May 2000)
# v3: v2 + ability to look at anybody's node/exp info - (26. Jun 2000)
#
# usage: e2exp.pl [e2 user]

use strict;

# in order of appearance ...
my ($user, @usernode, $f, $num, $exp);

if (!$ARGV[0]) { print "usage: e2exp.pl [e2 user]\n" and exit; }

foreach (@ARGV) { $user .= $_ . " "; }

$user =~ s/ $//;        # :)

# replace common non-alphanumeric chars with their
# respective url hex values.
$user =~ s/ /%20/g;
$user =~ s/\+/%2b/g;
$user =~ s/\[/%5b/g;
$user =~ s/\]/%5d/g;
$user =~ s/_/%5f/g;

@usernode = `lynx -source http://everything2.com/index.pl?node=$user`;

if ($usernode[10] =~ /Duplicates Found/) {
    foreach (@usernode) {
        chop;
        if ($_ =~ /\(user\)/) {
            $_ =~ s/\\.*$//;
            @usernode = `lynx -source http://everything2.com$_`;
            last;
        }
    }
}

$f = 0;

foreach (@usernode) {
    chop;
    if ($f == 1) {
        $_ =~ s/\<.+?\>//g;
        ($num, $exp) = split(/\//, $_);
        last;
    }
    if ($_ =~ /experience/) { $f = 1 }
}

print "\n   nodes: $num\n";
print "     exp: $exp\n";
print "exp/node: " . substr($exp/$num, 0, 3) . "\n\n";

# eop.


version 0.4: got rid of the `lynx` kludge and started using LWP .. and URI::Escape .. also cleaned some miscellaneous stuff up .. thanks to rescdsk and various other #everything-ites for debug help, etc.

#!/usr/bin/perl -w
#
# ithron (ithron@charter.net)
# e2exp.pl
#
# 0.4 (06/27/00): using LWP and uri::escape now, some code clean up, etc.
# 0.3 (06/26/00): 0.2 + ability to look at anybody's node/exp info.
# 0.2 (05/28/00): show exp to node ratio.         
# 0.1 (05/25/00): pull down my current exp on e2.
#     
# usage: e2exp.pl [e2 user]

use strict;
use LWP::Simple;
use URI::Escape;

my $version = "0.4";

# in order of appearance ...
my ($user, @usernode, $f, $num, $exp);

if (!$ARGV[0]) || ($ARGV[0] =~ /-(h|(-)?help)/) || ($ARGV[0] =~ /-(v|V|(-)?ver(sion)?)/)) { 
    print "e2exp.pl ver. $version\n";
    print "by ithron (ithron\@charter.net)\n\n";
    print "usage: e2exp.pl [e2 user]\n";
    exit; 
}

foreach (@ARGV) { $user .= $_ . " "; }

$user =~ s/ $//;        # :)
$user = uri_escape($user, "^A-Za-z0-9");
@usernode = split(/\n/, get("http://everything2.com/index.pl?node=$user"));

if ($usernode[10] =~ /Duplicates Found/) {
    foreach (@usernode) {
        chomp;
        if ($_ =~ /\(user\)/) {
            $_ =~ s/\\.*$//;
            @usernode = split(/\n/, get("http://everything2.com$_"));
            last;
        }
    }
}

$f = 0;

foreach (@usernode) {
    chomp;
    if ($f == 1) { 
        $_ =~ s/\<.+?\>//g;
        if ($_ !~ /n\/a/) { ($num, $exp) = split(/\//, $_); }
        else { print "this is a special user. nodes/exp are not applicable.\n" and exit; }
        last;
    }
    if ($_ =~ /experience/) { $f = 1 }
}

print "\n   nodes: $num\n";
print "     exp: $exp\n";
print "exp/node: " . substr($exp/$num, 0, 4) . "\n\n";

# eop.

version 0.5: This version is by the same author. When I tried to run 0.4, it choked because the layout of the home nodes is a bit different now. The author updated the script basically because I asked him to. Nice guy. :) You may have problems using this script off this web page so I put it on http://hongpong.dyndns.org/perl/e2exp.pl for possibly better functionality.



#!/usr/bin/perl -w
# ithron@charter.net
# e2exp.pl
#
# More info by HongPong: this script accesses the internet knowledge database
# www.everything2.com and determines a user's important metrics, specifically,
# their XP and their node count. For more info write the author at ithron@charter.net.
# To execute the script enter 'perl -w e2exp.pl [username]' on your command line.
# Visit http://www.everything2.com/index.pl?node=e2exp.pl for the latest info.
#
# 0.5 (06/14/01): update for new user home page format. Also uses a different get URL
# to prevent "Duplicates found" confusion.
# 0.4 (06/27/00): using LWP and uri::escape now, some code clean up, etc.
# 0.3 (06/26/00): 0.2 + ability to look at anybody's node/exp info.
# 0.2 (05/28/00): show exp to node ratio.         
# 0.1 (05/25/00): pull down my current exp on e2.
# 
# usage: e2exp.pl [e2 user]
#

use strict;
use LWP::Simple;
use URI::Escape;

my $version = "0.5";

# in order of appearance ...
my ($user, @usernode, $f, $num, $exp);

if ((!$ARGV[0]) || ($ARGV[0] =~ /-(h|(-)?help)/) || ($ARGV[0] =~ /-(v|V|(-)?ver(sion)?)/)) { 
print <\.*$//;
	    @usernode = split(/\n/, get("http://everything2.com$_"));
	    last;
	}
    }
}

$f = 0;

foreach (@usernode) {
    chomp;
    if ($_ =~ /experience/) { 
	$_ =~ s/\<.+?\>//g;
	$_ =~ s/number of write\-ups\/experience//;
	if ($_ !~ /n\/a/) { ($num, $exp) = split(/\//, $_); }
	else { print "this is a special user. nodes/exp are not applicable.\n" and exit; }
	last;
    }
}

print "\n   nodes: $num\n";
print "     exp: $exp\n";
print "exp/node: " . $exp/$num . "\n\n";

# eop.

Log in or register to write something here or to contact authors.