I’m learning Perl! :)
#!/usr/bin/perl -w
use strict;
use XML::Atom::Client;
use Text::Wrap;
$Text::Wrap::columns = 76;
my $atomapi = XML::Atom::Client->new;
my $o;
MAINLOOP: {
eval {
my $f = $atomapi->getFeed(”http://4q.cc/index.php?pid=atom&person=all“);
my @entry = $f->entries;
my $e = $entry[0];
$o = $e->elem->getChildrenByTagName(”title”)->shift->firstChild->data;
};
if ($@) {
redo MAINLOOP;
}
}
$o = “\n\033[1;34m” . fill(”\033[1;34m”, “\033[1;34m”, “FUN FACT: $o”) . “\n\n”;
$o =~ s/\033\[1;34m\033\[1;34m/\033[1;34m/g;
open(MOTD, “>/etc/motd”);
print MOTD $o;
truncate(MOTD, length($o));
on 25 Dec 2006 at 12:51 pm 1.Randal L. Schwartz said …
Why do you have the first part in an eval block? Does it die a lot?
on 11 Mar 2007 at 10:02 pm 2.existingthing said …
[insert randomly selected compaint about your code here]
[insert another randomly selected compaint about your code here]
Don’t listen to anyone else. The great thing about perl, is that it allows you to be as quick and dirty as you want. Pretty good start. I’d highly recommend digging up some quality sample code, you’ll pick up all kinds of shortcuts, and tips by looking at someone else’s code.
Now I love making my scripts use as few lines as possible while being somewhat understandable