#!/usr/bin/perl -w # ############################################################################ # # Name: dirlicious.pl # Author: Pete Prodoehl # Author-Email: pete@rasterweb.net # # $Id: dirlicious.pl,v 1.3 2004/09/09 21:00:21 pete Exp pete $ # # run like so: perl dirlicious.pl delicious.xml >dirlicious.html # # or like so: cat delicious.xml | perl dirlicious.pl >dirlicious.html # # or like this (all on one line of course, and not too often!) # # curl -u username:password # "http://del.icio.us/api/posts/recent?count=10000" | # perl dirlicious.pl >dirlicious.html # ############################################################################ ############################################################################ # use strict; use XML::Simple; use HTML::Entities; my $xml; { local($/) = undef; $xml = <>; } my $info = XML::Simple::XMLin($xml); my $data = $info->{post}; my @posts = @$data; my %tags; my %hashes; for my $post (@posts) { my $hash = $post->{hash}; my $description = encode_entities($post->{description}); my $href = $post->{href}; my $tag = $post->{tag}; $href =~ s/&/&/g; $hashes{$hash} = "$description\t$href"; my @tags = split (" ", $tag); my $thetag; foreach $thetag (@tags) { if (!(defined($tags{$thetag}))) { $tags{$thetag} = $hash; } else { $tags{$thetag} .= "\t" . $hash; } } } &print_header; my $tag; my @tags = sort keys (%tags); my $post; my $description; my $href; foreach $tag (@tags) { printf qq|\n