Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
use strict; use LWP; use Term::ReadKey; use Getopt::Std; use XML::Simple; use HTTP::Request::Common; use HTML::Template; use constant URL => ''; $| = 1; use vars qw(%opts); getopts('p:u:h',\%opts); my ($user,$passwd,$help) = parse_args(\%opts); USAGE() and exit unless $user and $passwd and not $help; my $ua = LWP::UserAgent->new; $ua->agent("all_node_grabber($user)/1.0 (" . $ua->agent .')'); # log in and access your nodes info xml page my $request = POST(URL, Content => [ op => 'login', user => $user, passwd => $passwd, node => 'User nodes info xml generator', ]); my $response = $ua->request($request); # prepare xml my $xml = $response->content(); # i have two nodes that have the registerd and copyright # symbols in them - the next two lines were necesary - YMMV $xml =~ s///g; $xml =~ s///g; $xml = XMLin($xml,forcearray=>1) or die "xml error!"; # munge data my %bookmarks; my $marker = qr/<!--\s*([a-z]+)\s*-->/; # YMMV here too while(my($node_id,$hash) = each %{$xml->{'NODE'}}) { my $content = $hash->{'content'}; my ($category) = $content =~ /$marker/; next unless $category; # the next three lines are specific to me - YMMV $category = ucfirst $category . 's'; $content =~ s/$marker(?:\($user\))*\s*\d*//; $content =~ s/(.{24}).{3,}/$1.../; push @{$bookmarks{$category}}, {id=>$node_id, content=>$content}; } # prepare template my $html = do {local $/; <DATA>}; my $template = HTML::Template->new( scalarref => \$html); $template->param( categories => [ map {{ category => $_, nodes => $bookmarks{$_} }} sort keys %bookmarks # feel free to customize this sort ]); # print template print $template->output(); sub parse_args { my %opt = %{+shift}; if (exists $opt{'p'} and not defined $opt{'p'} and defined $opt{'u' +}) { print "Enter password: "; ReadMode 'noecho'; chomp($opt{'p'} = ReadLine 0); ReadMode 'normal'; } return @opt{qw(u p h)}; } sub USAGE { print "USAGE: $0 -u user -p -password\n" } =pod =head1 NAME - LWP script =head1 DESCRIPTION This is a simple script that uses LWP, XML::Simple, and HTML::Template to produce an HTML table of nodes whose titles you have marked with an HMTL comment, such as <!--code--> or <!--neatstuff-->. The HTML template is included in the DATA handle for you convenience, simply change it to suite your needs. =head1 SYNOPSIS for *nix: ./ -u uname -p for win32: perl -u uname -p Invokes the script for the specified username and interactively prompt for password if none specified. =cut __DATA__ <table width="200" border="1"> <tmpl_loop name="categories"> <tr><td> <font face="arial,geneva,sans-serif"> <u><tmpl_var name="category"></u> <font size="2"> <ul> <tmpl_loop name="nodes"> <li>[id://<tmpl_var name="id">|<tmpl_var name="content">] </tmpl_loop> </ul> </font></font> </td></tr> </tmpl_loop> </table>

In reply to Node Bookmark Lister by jeffa

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [marioroy]: Added MCE::Inbox demonstration to Re^3: Hobo with a bit of recursion. I need to include MCE::Inbox in the next MCE::Shared release. That was fun.

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (6)
    As of 2018-06-22 22:52 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (124 votes). Check out past polls.