January 2002
Beginner
480 pages
13h 15m
English
Any script over a certain size is likely to have some helper functions,
and our RSS news agent is no exception. Here we have the function to switch the
from and to attribute values of a
node (toFrom()), the function to remove the resource
from a JID (stripJID()), and something not much
better than a debugging-style print statement:
sub toFrom {
my $node = shift;
my $to = $node->attr('to');
$node->attr('to', $node->attr('from'));
$node->attr('from', $to);
return $node;
}
sub stripJID {
my $JID = shift;
$JID =~ s|/.*$||;
return $JID;
}
sub debug {
print STDERR "debug: ", @_, "\n";
}Read now
Unlock full access