Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-26 01:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found