Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
#!perl # repviewer parses the reputation file generated by jcwren's luke_repw +alker.pl # to generate a full list of your articles sorted by creation time, ti +tle or # reputation just like the one at perlmonks user search except that al +l # articles are displayed on one page. Just set $pm and $rep below. use strict; use CGI qw(:standard *table); use HTML::Entities; my$pm = 'http://perlmonks.org'; # your login domain for perlmonks, us +ed for node link my$rep = 'c:\.rep.epoptai'; # full path to rep file generated by luke_ +repwalker.pl my%i = map{$_ => param($_)} param; my($mode,$td,$ta,$rd,$ra,$ca,$cd); if($i{'o'} eq 'title DESC'){$mode='td'; $td='selected'} if($i{'o'} eq 'title ASC'){$mode='ta'; $ta='selected'} if($i{'o'} eq 'reputation DESC'){$mode='rd'; $rd='selected'} if($i{'o'} eq 'reputation ASC'){$mode='ra'; $ra='selected'} if($i{'o'} eq 'createtime ASC'){$mode='ca'; $ca='selected'} if(($i{'o'} eq 'createtime DESC') or (!$i{'o'})){$mode='cd'; $cd='sele +cted'} print header,start_html(-title=>'repviewer',-bgcolor=>'#a0a0a0'); print<<HTML; # perlmonks sort form <style><!-- td{ font-family: arial ; font-size: 80% ;} // --></style> <FORM> Order By: <SELECT NAME="o"> <OPTION $td VALUE="title DESC">By Title Reverse <OPTION $ta VALUE="title ASC">By Title <OPTION $ra VALUE="reputation ASC">Lowest Reputation First <OPTION $rd VALUE="reputation DESC">Highest Reputation First <OPTION $ca VALUE="createtime ASC">Oldest First <OPTION $cd VALUE="createtime DESC">Newest First</SELECT> <INPUT TYPE="submit" VALUE="sort"></FORM> <blockquote><pre> HTML open(REP,"< $rep") or die "$!"; my@rep=<REP>; die "$!" unless close(REP); my(%reps,%tits,%dates,@reps,@tits,$tot); for(@rep){ $_=~m/^"(\d+)","(.*)","(-?\d+)","(.*)"$/; my$node = $1; my$title= $2; my$rep = $3; my$date = $4; &encode_entities($title); $reps{$node}=$rep; $tits{$node}=$title; $dates{$node}=$date; } for(values(%reps)){ $tot += $_ } for(keys(%tits)){ push @tits, $tits{$_}.'=|||='.$_ } my$i=1; printf (" Total articles: %d\n", scalar @rep); # nod to luke printf (" Total reputation: %d\n", $tot); printf ("Average reputation: %3.2f\n", $tot / scalar @rep); print '</pre></blockquote>'; if($mode=~/td|ta/){ # by title print start_table({-border=>'1',-cellpadding=>'2',-cellspacing=>'1 +',-bgcolor=>'#c0c0c0'}); print '<tr bgcolor="#ffffff"><td>num<td><b>title<td>rep<td>date</t +r>'; if($mode=~/ta/){ # ascending for(sort{ lc($a) cmp lc($b)}(@tits)){ my($f,$b)=split(/=\|\|\|=/,$_); print<<HTML; <tr> <td>$i</td> <td><a href="$pm/index.pl?node_id=$b">$f</a></td> <td align="right">$reps{$b}</td> <td>$dates{$b}</td></tr> HTML $i++ } } if($mode=~/td/){ # descending for(reverse(sort{ lc($a) cmp lc($b)}(@tits))){ my($f,$b)=split(/=\|\|\|=/,$_); print<<HTML; <tr> <td>$i</td> <td><a href="$pm/index.pl?node_id=$b">$f</a></td> <td align="right">$reps{$b}</td> <td>$dates{$b}</td></tr> HTML $i++ } } print end_table,end_html; exit } if($mode=~/cd|ca/){ # by date print start_table({-border=>'1',-cellpadding=>'3',-cellspacing=>'1 +',-bgcolor=>'#c0c0c0'}); print '<tr bgcolor="#ffffff"><td>num<td>title<td>rep<td><b>date</t +r>'; } if($mode eq 'cd'){@rep=reverse(@rep)} # descending my$i=1; for(@rep){ $_=~m/^"(\d+)","(.*)","(-?\d+)","(.*)"$/; my$node = $1; my$title= $2; my$rep = $3; my$date = $4; &encode_entities($title); $reps{$node}=$rep; $tits{$node}=$title; $dates{$node}=$date; if($mode=~/cd|ca/){ print<<HTML; <tr> <td>$i</td> <td><a href="$pm/index.pl?node_id=$node">$title</a></td> <td align="right">$rep</td> <td>$date</td></tr> HTML } $i++ } if($mode=~/cd|ca/){ print end_table,end_html; exit } if($mode=~/rd|ra/){ # by rep print start_table({-border=>'1',-cellpadding=>'3',-cellspacing=>'1 +',-bgcolor=>'#c0c0c0'}); for(keys(%reps)){ push @reps, $reps{$_}.'='.$_ # construct a sortable rep array } for(@reps){ my($a,$b)=split(/=/,$_); if($a < 10){ $_=~s/(\d)/0$1/o # pad for sort } } $i=1; print '<tr bgcolor="#ffffff"><td>num<td>title<td><b>rep<td>date</t +r>'; if($mode=~/rd/){ for(reverse(sort{$a cmp $b}(@reps))){ # descending my($f,$b)=split(/=/,$_); if($f=~/^0\d$/){$f=~s/^0//o} # strip sort padding if($f=~/^-0\d$/){$f=~s/^-0/-/o} print<<HTML; <tr> <td>$i</td> <td><a href="$pm/index.pl?node_id=$b">$tits{$b}</a></td> <td align="right">$f</td> <td>$dates{$b}</td></tr> HTML $i++ } } if($mode=~/ra/){ # ascending for(sort{$a cmp $b}(@reps)){ my($f,$b)=split(/=/,$_); if($f=~/^0\d$/){$f=~s/^0//o} if($f=~/^-0\d$/){$f=~s/^-0/-/o} print<<HTML; <tr> <td>$i</td> <td><a href="$pm/index.pl?node_id=$b">$tits{$b}</a></td> <td align="right">$f</td> <td>$dates{$b}</td></tr> HTML $i++ } } print end_table,end_html; } exit

In reply to repviewer by epoptai

Title:
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!
  • 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?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (8)
    As of 2015-07-07 11:41 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (88 votes), past polls