[26842] in Perl-Users-Digest
Perl-Users Digest, Issue: 8867 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 19 09:05:36 2006
Date: Thu, 19 Jan 2006 06:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 19 Jan 2006 Volume: 10 Number: 8867
Today's topics:
Re: hash mystery (Anno Siegel)
randomly choose some uniq elements of an array <news@chaos-net.de>
Validating massive amounts of external links <njus@larshaugseth.com>
Re: Validating massive amounts of external links <1usa@llenroc.ude.invalid>
Re: Validating massive amounts of external links <noreply@gunnar.cc>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Jan 2006 11:33:41 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: hash mystery
Message-Id: <dqntel$17f$1@mamenchi.zrz.TU-Berlin.DE>
Darren Dunham <ddunham@redwood.taos.com> wrote in comp.lang.perl.misc:
> monkeys paw <steve@statenet.com> wrote:
> > For some reason i'm forced to use a scalar for
> > ONE hash element and not the rest. Here is how the
> > code behaves:
>
> > my $id = $qry->param('id' . $1);
>
> perhaps param('id' . $1) is multivalued?
That's certainly what it looks like. If so,
%hash = (
# ...
id => scalar $qry->param('file_name' . $1),
# ...
);
should solve it.
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
Date: Thu, 19 Jan 2006 14:38:18 +0100
From: Martin Kissner <news@chaos-net.de>
Subject: randomly choose some uniq elements of an array
Message-Id: <slrndsv5ia.4l2.news@maki.homeunix.net>
hello together,
I want to choose a number of files from a directory randomly.
This is what I have so far (after reading "perlodc -f "How do I shuffle
an array randomly?"").
-------
#!/usr/bin/perl
use warnings;
use strict;
my $dir = "/path/to/folder";
opendir DH, $dir || die "can not open $dir: $!";
my @files = grep !/^\.\.?$|/ ,readdir DH;
closedir DH;
my @shuffled;
while (@files) {
# the FAQ says this is bad
push(@shuffled, splice(@files, rand @files, 1));
}
for (1..3) {
print pop @shuffled,"\n";
}
-------
I am pretty sure that there is a better an simpler solution.
Any suggestions will be appreciated.
Regards
Martin
--
perl -e '$S=[[73,116,114,115,31,96],[108,109,114,102,99,112],
[29,77,98,111,105,29],[100,93,95,103,97,110]];
for(0..3){for$s(0..5){print(chr($S->[$_]->[$s]+$_+1))}}'
------------------------------
Date: Thu, 19 Jan 2006 12:00:09 GMT
From: Lars Haugseth <njus@larshaugseth.com>
Subject: Validating massive amounts of external links
Message-Id: <877j8w5tb0.fsf@onyxia.eiendomsnett.no>
I have a database with a table containing (among others) the columns
URL, STATUS and LASTCHECKED. Stored in the table are thousand of records
containg links to external resources (all using the HTTP protocol.)
I need to develop a tool to periodically go through all the links stored
in the table, and update their status (ALIVE, TEMPORARY UNAVAILABLE, DEAD)
based on some criteria. For example, DEAD might mean that the resource has
not responded successfully for the last N days (for some value of N.)
Checking each link in sequence could take several days, depending on the
timeout limit when doing a request. Thus, the checking should be performed
in multiple threads/processes.
For now, I'm only interested in the HTTP response code and whether there
was a timeout, but later I may wish to validate the actual content returned
as well.
I'm just about to start implementing this using LWP::UserAgent and doing
everything else from scratch, but if any modules or tools exists that would
reduce the effort I have to put into this, I would be very grateful if
someone were to direct me to them.
--
Lars Haugseth
------------------------------
Date: Thu, 19 Jan 2006 12:11:28 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Validating massive amounts of external links
Message-Id: <Xns97504937521FAasu1cornelledu@127.0.0.1>
Lars Haugseth <njus@larshaugseth.com> wrote in
news:877j8w5tb0.fsf@onyxia.eiendomsnett.no:
> I need to develop a tool to periodically go through all the links
> stored in the table, and update their status
...
> I'm just about to start implementing this using LWP::UserAgent and
> doing everything else from scratch,
http://search.cpan.org/~marclang/ParallelUserAgent-2.57/lib/LWP/Parallel/RobotUA.pm
I haven't used it, but it looks promising.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Thu, 19 Jan 2006 13:23:19 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Validating massive amounts of external links
Message-Id: <439ehpF1ltfu7U1@individual.net>
Lars Haugseth wrote:
> I need to develop a tool to periodically go through all the links stored
> in the table, and update their status
<snip>
> I'm just about to start implementing this using LWP::UserAgent and doing
> everything else from scratch, but if any modules or tools exists that would
> reduce the effort I have to put into this, I would be very grateful if
> someone were to direct me to them.
I have successfully done something similar using LWP::UserAgent and
Parallel::ForkManager.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 8867
***************************************