Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

zdog's scratchpad

by zdog (Priest)
on Jun 02, 2004 at 01:50 UTC ( #358978=scratchpad: print w/ replies, xml ) Need Help??

PROPOSAL: Most contraversial nodes

This is something I've been thinking about for a while now and spoken to vroom about on a number of occasions. I figured it was time to stop talking and finally do something. Here is the preliminary code for obtaining the data:

my $dbh = $DB->getDatabaseHandle(); my $nodeids = $dbh->selectcol_arrayref("SELECT DISTINCT vote_id FROM v +ote"); my $uph = $dbh->prepare("SELECT COUNT(*) FROM vote WHERE vote_id=? AND + weight > 0"); my $dnh = $dbh->prepare("SELECT COUNT(*) FROM vote WHERE vote_id=? AND + weight < 0"); my @cnodes = (); NODEID: while ( @$nodeids ) { for ( 1 .. 100 ) { if ( my $nodeid = shift @nodeids ) { $uph->execute( $nodeid ); $dnh->execute( $nodeid ); my ($upvotes) = $uph->fetchrow_array; my ($downvotes) = $dnh->fetchrow_array; push @cnodes, [ $nodeid, ( $upvotes < $downvotes ) ? $upvotes : $downvotes ]; } else { last NODEID; } } trim( \@cnodes ); } trim( \@cnodes ); # display @cnodes ############### sub trim { my ( $cnodes ) = @_; @$cnodes = sort { $a->[1] <=> $b->[1] } @$cnodes; shift @$cnodes while @$cnodes > 30; }

All this is untested in any way, shape, or form. I'm not even sure that all of it is Perl. This is a work in progress. All comments, questions, and suggestions are welcome.






Just some nodes I want to take a look at later on:

converting Time::HiRes
Re: join doesn't seem to insert separators
Global variable vs passing variable from sub to sub
Automating File Rotation
Re: Is there an equivalent $. for lists or arrays in map or foreach? (mapcar!)
What the heck does $|++; do?
Discover a package global's symbol name given a reference
digitally sign XML Document
How can I compare two directories and copy over files missing from one to another?
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 lurking in the Monastery: (16)
As of 2014-07-25 18:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (174 votes), past polls