[23741] in Perl-Users-Digest
Perl-Users Digest, Issue: 5947 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 17 06:06:05 2003
Date: Wed, 17 Dec 2003 03:05:08 -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 Wed, 17 Dec 2003 Volume: 10 Number: 5947
Today's topics:
Re: [HELP] code modification <matthew.garrish@sympatico.ca>
Re: [HELP] code modification <paul.sellis@alussinan.org>
Re: Asynchronous Objects <troc@pobox.com>
Re: encrypt email address to a string <tony_curtis32@_SPAMTRAP_yahoo.com>
Re: error in Compress-Zlib-1.32 <linh@chello.no>
Re: How to determine end-of-line sequence? (David Efflandt)
Re: How to determine end-of-line sequence? <jill_krugman@yahoo.com>
Re: How to disable print() function buffering in perl? <vm.mayer@comcast.net>
HTML::Form->Parse (Perl) not working under Fedora Core (Jeffrey J. Kosowsky)
Re: HTML::Form->Parse (Perl) not working under Fedora C <noreply@gunnar.cc>
Re: HTML::Form->Parse (Perl) not working under Fedora C (Jeffrey J. Kosowsky)
Indigo httpd.conf - mod_perl.so cannot be loaded (Nele Paulsen)
Re: Indigo httpd.conf - mod_perl.so cannot be loaded <carsten@welcomes-you.com>
Re: Login to site with random image code? <pkent77tea@yahoo.com.tea>
Re: Perl equivalent of "On error resume" (Rajesh)
Re: Problem using Archive::Zip ! <vertica.garg@siemens.com>
reading from an url (Rajesh)
Re: reading from an url <nospam@bigpond.com>
Re: reading from an url <tassilo.parseval@rwth-aachen.de>
Return all points with x km of y <ianp@pop3.myrealbox.com>
Re: Return all points with x km of y <invalid-email@rochester.rr.com>
Re: Return all points with x km of y <nospam@bigpond.com>
Re: Return all points with x km of y <nospam@bigpond.com>
Re: Return all points with x km of y <nospam-abuse@ilyaz.org>
Simple text file operation (logic1)
Re: Simple text file operation (Anno Siegel)
Where do -T warnings go? <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 16 Dec 2003 20:05:35 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: [HELP] code modification
Message-Id: <mZNDb.6496$CK3.507675@news20.bellglobal.com>
"Paul Sellis" <paul.sellis@alussinan.org> wrote in message
news:paul.sellis-6E998F.18505316122003@news1-2.free.fr...
>
>
> I think that :
> d*\)
> must say something like "any digit and a right parenthesis". Et I should
> modify (at least) this part of code. But folks I need your help !
>
It would require more work than it's worth to fix such a hideous script.
You're better off using something newer:
http://nms-cgi.sourceforge.net/scripts.shtml
Matt
------------------------------
Date: Wed, 17 Dec 2003 12:04:19 +0100
From: Paul Sellis <paul.sellis@alussinan.org>
Subject: Re: [HELP] code modification
Message-Id: <paul.sellis-9A6DA4.12041817122003@news1-1.free.fr>
In article (Dans l'article)
<Xns9453CA1F4EF5Fasu1cornelledu@132.236.56.8>,
"A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu> wrote (écrivait) :
> Well, since your domain name include my name, here is some advice :) (What
> does alussinan mean anyway?
a french server that filters spam
thanks for all your answers and advises
------------------------------
Date: Wed, 17 Dec 2003 07:14:08 GMT
From: Rocco Caputo <troc@pobox.com>
Subject: Re: Asynchronous Objects
Message-Id: <slrnbu00p7.21j0.troc@eyrie.homenet>
On 15 Dec 2003 10:23:17 -0800, Bryan Castillo wrote:
> I've been looking through CPAN and the newsgroups for information on
> calling on objects asynchronously from perl. Basically, I was
> thinking about a Tk application I was working on that used DBI and had
> some SQL statements that may take 10 to 30 seconds. I really didn't
> want the screen to freeze for that long.
[...]
> Is there anything out there like this? I haven't been able to find
> anything on CPAN. There is RPC::PlServer and RPC::PlClient, however I
> was looking for something where the client would start the server on
> demmand (theoreticaly this could still be done with
> RPC::Pl(Server|Client), but I didn't want to use sockets), and I was
> looking for something that would allow asynchronous calls on the
> objects.
POE cooperates with Tk, and the CPAN has perhaps too many asynchronous
DBI abstractions available for it. The POE DBI components usually do
what you outlined, but they differ in their approaches to executing SQL
and managing child processes.
Look for POE DBI on http://search.cpan.org/
--
Rocco Caputo - rcaputo@pobox.com - http://poe.perl.org/
------------------------------
Date: Tue, 16 Dec 2003 20:07:22 -0600
From: Tony Curtis <tony_curtis32@_SPAMTRAP_yahoo.com>
Subject: Re: encrypt email address to a string
Message-Id: <87ekv4jixx.fsf@limey.hpcc.uh.edu>
>> On Tue, 16 Dec 2003 04:23:31 GMT,
>> "Reportor" <test@test.com> said:
>> > What I need to do is pretty simple. I need to add email
>> > address as a Referal, but I want it to look something >
>> different, so that spammers will not know that is an >
>> email. I don't want to keep a database to make member1 = >
>> abc@abc.com, member2 = abe@abe.us
>>
>> Why not?
>>
>> Maintaining a map of opaque tokens to email addresses
>> sounds like a really good solution. You could simply
>> create a configuration file to store this map, or even put
>> it in the source code.
>>
> I hate to use flock(). I am trying my best to avoid any
> WRITE to disk.
Why would you need to write? You'd just be reading a file to
look up a token's corresponding email address.
This also places a buffer between input data and the program's
actions; there's no way anyone can work out what the target
email address is from looking at publicly available
information and you can protect yourself from accepting email
addresses you don't want.
------------------------------
Date: Wed, 17 Dec 2003 11:28:25 +0100
From: ngoc <linh@chello.no>
Subject: Re: error in Compress-Zlib-1.32
Message-Id: <KmWDb.6235$n31.105423@news2.e.nsc.no>
Tony Curtis wrote:
>>>On Tue, 16 Dec 2003 21:51:12 +0100,
>>>ngoc <linh@chello.no> said:
>
>
>>Hi I got error below when running 'make' command in
>>installing Compress-Zlib-1.32. I do not know how to solve
>>it. Ngoc Thank for help.
>
>
>>-I/program/perl/lib/5.6.1/sun4-solaris/CORE inflate.c
>>/usr/ccs/bin/as: "/var/tmp/ccviQ61O.s", line 597: error:
>>unknown opcode ".subsection" /usr/ccs/bin/as:
>
>
> A Google search on
>
> unknown opcode ".subsection"
>
> will provide the answer.
Hi
I download binutils and install . I can install package after that.
But when running pp -o program_file program_file.pl
It gives error: Can not find the par loader.
Looking at my Linux installation(successful install), it has 'parl'
program, but Solaris does not have. Searching from the web,<problem
occur when do not have parl and not c compiler>. I am sure that C
compiler is in place.Because packages can 'make'. How can i get 'parl'?
Ngoc
------------------------------
Date: Wed, 17 Dec 2003 03:21:25 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: How to determine end-of-line sequence?
Message-Id: <slrnbtvitl.d2h.efflandt@typhoon.xnet.com>
On Tue, 16 Dec 2003, J Krugman <jill_krugman@yahoo.com> wrote:
>
> I'm writing a cgi script that uploads and processes files. These
> files can come from Windows, Linux, or Macintosh machines, so the
> script doesn't know ahead of time the end-of-line conventions used
> by the uploaded files. What is the best way for a script to
> determine the end-of-line sequence used by a given text file?
It is probably best to correct it to what you want regardless of what it
is. Following is a script I wrote awhile ago that converts any text file
type to what you want based on the script name, but could be easily
modified (shortened) to convert to a single type:
#!/usr/bin/perl -w
# txtconv - convert text to or from other OS
# Symlink or rename any of: tounix, 2unix, todos, 2dos, tomac, 2mac
# follow with list of files on commandline
# "tomac" may conflict with a program name
while(@ARGV) {
my $file = shift @ARGV;
unless (open(FILE,"+< $file")) {warn "Can't open $file: $!\n"; next;}
flock(FILE,2); seek(FILE,0,0); binmode FILE;
print "$file before ", -s $file;
my @lines = <FILE>; seek(FILE,0,0); truncate(FILE,0);
if (lc($0) =~ /2unix|tounix/) { $end = "\012" }
elsif (lc($0) =~ /2dos|todos/) { $end = "\015\012" }
elsif (lc($0) =~ /2mac|tomac/) { $end = "\015" }
else { die "file not converted, read $0\n" }
foreach (@lines) { s/(\015\012|[\015\012])/$end/g; print FILE $_; }
close FILE;
print " after ", -s $file,"\n";
}
--
David Efflandt - All spam ignored http://www.de-srv.com/
------------------------------
Date: Wed, 17 Dec 2003 04:14:07 +0000 (UTC)
From: J Krugman <jill_krugman@yahoo.com>
Subject: Re: How to determine end-of-line sequence?
Message-Id: <brol6f$mk5$1@reader2.panix.com>
In <slrnbtvitl.d2h.efflandt@typhoon.xnet.com> efflandt@xnet.com (David Efflandt) writes:
>On Tue, 16 Dec 2003, J Krugman <jill_krugman@yahoo.com> wrote:
>>
>> I'm writing a cgi script that uploads and processes files. These
>> files can come from Windows, Linux, or Macintosh machines, so the
>> script doesn't know ahead of time the end-of-line conventions used
>> by the uploaded files. What is the best way for a script to
>> determine the end-of-line sequence used by a given text file?
>It is probably best to correct it to what you want regardless of what it
>is. Following is a script I wrote awhile ago that converts any text file
>type to what you want based on the script name, but could be easily
>modified (shortened) to convert to a single type:
>#!/usr/bin/perl -w
># txtconv - convert text to or from other OS
># Symlink or rename any of: tounix, 2unix, todos, 2dos, tomac, 2mac
># follow with list of files on commandline
># "tomac" may conflict with a program name
>while(@ARGV) {
> my $file = shift @ARGV;
> unless (open(FILE,"+< $file")) {warn "Can't open $file: $!\n"; next;}
> flock(FILE,2); seek(FILE,0,0); binmode FILE;
> print "$file before ", -s $file;
> my @lines = <FILE>; seek(FILE,0,0); truncate(FILE,0);
> if (lc($0) =~ /2unix|tounix/) { $end = "\012" }
> elsif (lc($0) =~ /2dos|todos/) { $end = "\015\012" }
> elsif (lc($0) =~ /2mac|tomac/) { $end = "\015" }
> else { die "file not converted, read $0\n" }
> foreach (@lines) { s/(\015\012|[\015\012])/$end/g; print FILE $_; }
> close FILE;
> print " after ", -s $file,"\n";
>}
Cool. Thanks!
jill
------------------------------
Date: Tue, 16 Dec 2003 21:56:31 -0500
From: Mike Mayer <vm.mayer@comcast.net>
Subject: Re: How to disable print() function buffering in perl?
Message-Id: <vm.mayer-0A199C.21563016122003@news-east.ash.giganews.com>
In article <5iyzb.4083$uE6.575@nwrddc02.gnilink.net>,
"Jürgen Exner" <jurgenex@hotmail.com> wrote:
> KJ wrote:
>
> > <<On a side note, I know there is a command "cerr <<" in C++ that
> > outputs a line of text as an "error" to the screen. Basically it is a
> > high-priority call to the print queue and followed by an immediate
> > buffer flush. Is there such an error output in PERL that I could use?
> > Keep in mind, this is for debugging purposes and will NOT be used in
> > the program on a regular basis... >>
>
> Well, just write to stderr instead of to stdout
>
Be careful here. Standard out and standard error are more than just
two different buffering schemes... They are two different output
streams. Often (maybe even most of the time) both of these streams
appear in your terminal window. But, if you are attempting capture
the output via a pipe (either on the command line or via a
pipe/fork/exec from within code) you will not capture both the
standard out and standard error streams unless you explicitly
merge them into a single stream (again either via the command
line---in a shell dependent fashion---or via a dup in code).
I have seen more than one tool cause consternation because it
sent output to standard error or error messages to standard out.
mike
------------------------------
Date: Wed, 17 Dec 2003 05:19:07 GMT
From: kosowsky@consult.pretender (Jeffrey J. Kosowsky)
Subject: HTML::Form->Parse (Perl) not working under Fedora Core 1
Message-Id: <m2smjkvx6f.fsf@consult.pretender>
I have been having trouble getting the HTML::Form library to work
under Fedora Core 1 (perl 5.8.1-92 with perl-libwww-perl-5.65-6). For
some reason, the function HTML::Form->Parse doesn't return any forms
for me.
For example, the following simple perl script:
#! /usr/bin/perl
use HTML::Form;
use HTTP::Request;
use LWP;
my $ua = new LWP::UserAgent;
my $uri="http://www.google.com";
my $req = HTTP::Request->new(GET => $uri);
my $res = $ua->request($req);
print $res->content;
my $form = HTML::Form->parse($res->content, $res->base());
print "Form: ${form}\n";
Returns the source of the www.google.com page but fails to return the
obvious embedded form.
The only potential problem I see is that the library Form.pm is stored
under: /usr/lib/perl5/vendor_perl/5.8.0/HTML/Form.pm (rather than 5.8.1)
I did not have any problems with this previously under RH8.0 with perl
5.8.0-88 and perl-libwww-perl-5.65-2.noarch.rpm)
Has anything changed in perl? Am I doing something wrong here? Any
suggestions on what might be going on?
Thanks,
Jeff
------------------------------
Date: Wed, 17 Dec 2003 06:57:32 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: HTML::Form->Parse (Perl) not working under Fedora Core 1
Message-Id: <broree$5thfm$1@ID-184292.news.uni-berlin.de>
Jeffrey J. Kosowsky wrote:
> I have been having trouble getting the HTML::Form library to work
<snip>
> my $form = HTML::Form->parse($res->content, $res->base());
> print "Form: ${form}\n";
>
> ... fails to return the obvious embedded form.
You are printing the object reference! Please study the documentation
for the module you are trying to use.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 17 Dec 2003 07:03:36 GMT
From: kosowsky@consult.pretender (Jeffrey J. Kosowsky)
Subject: Re: HTML::Form->Parse (Perl) not working under Fedora Core 1
Message-Id: <m2oeu8vsca.fsf@consult.pretender>
Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
> Jeffrey J. Kosowsky wrote:
> > I have been having trouble getting the HTML::Form library to work
>
> <snip>
>
> > my $form = HTML::Form->parse($res->content, $res->base());
> > print "Form: ${form}\n";
> > ... fails to return the obvious embedded form.
>
> You are printing the object reference! Please study the documentation
> for the module you are trying to use.
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
I know that -- but the fact is that it returns an empty reference --
i.e. no form! (which is all I was trying to show with this short dummy script)
If you want to do it your way by printing say:
join(" ", $form->form);
I get the corresponding error message:
"Can't call method "form" on an undefined value at ./myscript.pl line 14"
which occurs presumably because no form is returned!
My approach was used just to simplify the script and get at the "root"
of the problem.
So... my question still stands...
------------------------------
Date: 17 Dec 2003 01:15:57 -0800
From: n.paulsen@gmx.net (Nele Paulsen)
Subject: Indigo httpd.conf - mod_perl.so cannot be loaded
Message-Id: <51cb6355.0312170115.5ae0a33e@posting.google.com>
Hi,
I've just downloaded the last version from the indigo page.
No error with setup, but apache service cannot be started because of
the following error:
Event-ID: 3299
The Apache service named reported the following error:
>>> Cannot load C:/indigoperl/apache/modules/mod_perl.so into server:
Module was not found.
C:/indigoperl/apache/modules/mod_perl.so exists.
I saw some simular error messages for Python in news groups but there
wasn't
realy a soltion, which I could adapt.
I made all lines according mod_perl to '#'-lines, than the apache
service starts.
#ISEXT BEGIN
# BEGIN MOD_PERL CONFIG
LoadModule perl_module modules/mod_perl.so
ScriptAlias /perl-bin/ "C:/indigoperl/apache/perl-bin/"
PerlSendHeader On
<Location /perl-bin>
SetHandler perl-script
PerlHandler ModPerl::Registry
Options ExecCGI
</Location>
# END MOD_PERL CONFIG
What module cannot be found?
TIA,
Nele
------------------------------
Date: Wed, 17 Dec 2003 10:25:57 +0100
From: Carsten Aulbert <carsten@welcomes-you.com>
Subject: Re: Indigo httpd.conf - mod_perl.so cannot be loaded
Message-Id: <brp7fe$5tg4h$1@ID-213226.news.uni-berlin.de>
Nele Paulsen wrote:
> What module cannot be found?
Just a blind guess from my side, since I never ran apache on win32:
Do you have to use backslashes instead of forward slashes, or does apache
translate them?
Sorry if I'm totally wrong
CA
------------------------------
Date: Wed, 17 Dec 2003 10:51:58 +0000
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Login to site with random image code?
Message-Id: <pkent77tea-75839F.10515717122003@ptb-nnrpp01.plus.net>
In article <oTGDb.323$Z57.278@newssvr27.news.prodigy.com>,
"Lucas Van Hieng" <l.v.g@moskuetiez.de> wrote:
> (http://www.starlance.us/MW4/)
>
> They recently redid the site, so now it requires that you enter the
> random 5 digit number shown on a png image. (Before there was no such
> extra security and I was able to POST with LWP:UserAgent.)
>
> Is there way at all around these things? I'm guessing that this would be
> easier than with what MSN and Yahoo use, which is often a scrambled
> mess. This site however uses uniform text (as if just typed into the
> image with text tool and saved.) Is there anyway to do some sort of OCR
> (char recognition) on the fly?
Funnily enough we're looking at implementing a similar system at work.
Aaanyway...
From looking at it it does appear that the image uses only 2 colours -
the foreground and the background. There seems to be a 1 pixel gap
between each digit. The code appears to use only the digits 0 to 9. The
font doesn't vary and seems to be a variable-width font. The image seems
to be the same as long as you have the same PHPSESSIONID cookie from
them.
Using this information one approach would be:
a) get the image
b) convert it into some format that you can manipulate from perl - GD
might be of use.
c) scan over all the columns to identify columns that contain all the
same colour - those may be the breaks between digits. Trim the leading
and trailing space too. Maybe trim the space above and below too.
d) extract each rectangular area that is probably a digit.
e) the characters vary in size - use the size of the area to identify
some (maybe all) of the digits.
f) or somehow compare the rectangle's contents to digits you've matched
by hand and then you know what the digit is.
I'm not suggesting that you should actually do any of this, because that
may violate their terms of service etc, but it's an interesting problem
to think about. I see from another article that asking the site's admin
didn't help you out - but at leat you tried that approach too.
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: 16 Dec 2003 23:16:57 -0800
From: raj1_iit@yahoo.com (Rajesh)
Subject: Re: Perl equivalent of "On error resume"
Message-Id: <bb6dafde.0312162316.694aaff7@posting.google.com>
>
> $val = $thingy->GetValues if defined($thingy); # not real code
>
> before you try to call a method on it?
>
Thanks a lot. Actually i didnt know how to check if the object exists or not.
That surely helped.
------------------------------
Date: Wed, 17 Dec 2003 10:00:59 -0000
From: "Vertica Garg" <vertica.garg@siemens.com>
Subject: Re: Problem using Archive::Zip !
Message-Id: <brp9gq$pbi$1@news.mch.sbs.de>
Try using:
my @members = $zip->memberNames();
my $member = $zip->memberNamed($members[0]);
$member->desiredCompressionMethod(COMPRESSION_DEFLATED );
$member->desiredCompressionLevel(5);
Regards,
Vertica
"Bill" <wherrera@lynxview.com> wrote in message
news:239ce42f.0310251159.39a06353@posting.google.com...
> Ej <ustsurge@mailcan.com_NOSPAM> wrote in message
news:<61a8bde58a3ae71a347da52a73009cb8@news.bubbanews.com>...
> > "J. Gleixner" <glex_nospam@qwest.invalid> wrote in
> > news:99Wlb.2251$4V5.29115@news.uswest.net:
> > >> I get this message:
> > >> Can't call od "desiredCompressionMethod" without a package or
> > >> object reference at zp1.pl line 38.
> > >>
> > >>
> > >> however, this does work,
> > >>
> > >> foreach $ia (@fla){
> > >>
> > >> print "adding $ia<br>";
> > >> $status=$zip->addTree( "$ia","$ia" );
> > >> }
> > >>
>
> > can someone PLEASE post an example code using $zip->addTree('','')
> > that works or maybe this is a bug in Archive::Zip, that does not work.
> >
> > thank you.
>
> Something like this, maybe?
>
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
> use strict;
> use Carp;
> use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
> use Archive::Zip::Tree;
>
> my $rootdir = '/tmp';
> my $archname = 'archived.zip';
> my $destfile = $rootdir . '/' . $archname;
>
> my $bytesdone = 0;
> my $progress = sub {
> my $f = $_;
> return 0 unless(-f $f and lc $f ne $archname);
> $bytesdone += -s $f;
> print $bytesdone, " total bytes archived ",
>
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\
b";
> return 1;
> };
>
> my $zip = new Archive::Zip or carp("Cannot make zip object: $!");
> print "\nZipping directory $rootdir as $destfile\n";
> $zip->addTree($rootdir, undef, $progress) == AZ_OK
> or die "No good adding tree $rootdir";
> my @members = $zip->members;
> my $member = $members[0];
> $member->desiredCompressionMethod(COMPRESSION_DEFLATED);
> $member->desiredCompressionLevel(5);
> $zip->writeToFileNamed($destfile) == AZ_OK or
> carp ("Write error for zip object to $destfile: $!");
> print "\nDone.\n";
>
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
------------------------------
Date: 16 Dec 2003 23:36:10 -0800
From: raj1_iit@yahoo.com (Rajesh)
Subject: reading from an url
Message-Id: <bb6dafde.0312162336.1836cba5@posting.google.com>
Hi,
I checked the archives and faq in Perl. ostly from the archives, I got
to put up the following code to read from an url. But, if i run this
code i get the error,
500: Can't connect to www.yahoo.com:80 ((Bad hostname www.yahoo.com)
I believe it has something to do with internet connectivity. But, i
can acces the page using Internet explorer. So, do i have to specify
some proxy or something in the program?
Or is something wrong with the script?
P.S... I am running the perl script in Windows XP.
#!/usr/local/bin/perl -w
use LWP::Simple;
use LWP::UserAgent;
$url = "http://www.yahoo.com";
$ua = new LWP::UserAgent;
$ua->agent("$0/0.1");
$req = new HTTP::Request 'HEAD', $url;
$req->header('Accept' => 'text/html');
# send request
$res = $ua->request($req);
# check the outcome
if ($res->is_success) {
print "The link <$url> is ok.\n";
} else {
print "<$url>\n";
print " " . $res->code . " " . $res->message . "\n\n";
}
Rajesh
------------------------------
Date: Wed, 17 Dec 2003 18:58:38 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: reading from an url
Message-Id: <1921693.jOup5JDCf7@gregs-web-hosting-and-pickle-farming>
It was a dark and stormy night, and Rajesh managed to scribble:
> Hi,
>
> I checked the archives and faq in Perl. ostly from the archives, I got
> to put up the following code to read from an url. But, if i run this
> code i get the error,
> 500: Can't connect to www.yahoo.com:80 ((Bad hostname www.yahoo.com)
>
> I believe it has something to do with internet connectivity. But, i
> can acces the page using Internet explorer. So, do i have to specify
> some proxy or something in the program?
> Or is something wrong with the script?
> P.S... I am running the perl script in Windows XP.
Yahoo has code to stop you doing automatic downloads.
gtoomey
------------------------------
Date: 17 Dec 2003 09:23:52 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: reading from an url
Message-Id: <brp7b8$kk8$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Gregory Toomey:
> It was a dark and stormy night, and Rajesh managed to scribble:
>
>> Hi,
>>
>> I checked the archives and faq in Perl. ostly from the archives, I got
>> to put up the following code to read from an url. But, if i run this
>> code i get the error,
>> 500: Can't connect to www.yahoo.com:80 ((Bad hostname www.yahoo.com)
>>
>> I believe it has something to do with internet connectivity. But, i
>> can acces the page using Internet explorer. So, do i have to specify
>> some proxy or something in the program?
>> Or is something wrong with the script?
>> P.S... I am running the perl script in Windows XP.
>
> Yahoo has code to stop you doing automatic downloads.
But this can't be the explanation here since the OP's snippet works fine
for me and produces
The link <http://www.yahoo.com> is ok.
It must be a network problem. When I bogify the URL to
<http://wwwwwwwwwwwwww.yahoo.com> I get the same message the OP got.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Tue, 16 Dec 2003 21:40:49 -0500
From: "Ian Pattison" <ianp@pop3.myrealbox.com>
Subject: Return all points with x km of y
Message-Id: <brofms$5qhfs$1@ID-200856.news.uni-berlin.de>
Hi,
I'm trying to put together what I think is a fairly complex database query.
I have a table of about 32,000 latitiude and longitude pairs and I need to
be able to query for two different things:
1. All points that are within X kilometers (or miles for that matter) of
coordinate Y (both are supplied from an HTML form).
2. The nearest X points to coordinate Y (again, supplied by a form).
The first should be simple enough... I already know how to measure the
distance between two points (once I translate all that trig into perl) so
all I need to do is run the query and discard any result that's outside the
circle. The second is tougher. Does anyone know how to sort a list like
that?
Thanks,
Ian
------------------------------
Date: Wed, 17 Dec 2003 03:16:12 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Return all points with x km of y
Message-Id: <3FDFC87D.2010909@rochester.rr.com>
Ian Pattison wrote:
> Hi,
>
> I'm trying to put together what I think is a fairly complex database query.
Question about your terminology: by the term "database query", do you
mean something written in SQL requesting data from a relational
database? That is what that term generally means to computer
programmers. I'm no SQL expert, but queries of the form you mention are
generally not SQL-ish things. So I'll assume your "database" is
something more like a flat file consisting of two numbers per record.
>
> I have a table of about 32,000 latitiude and longitude pairs and I need to
> be able to query for two different things:
>
> 1. All points that are within X kilometers (or miles for that matter) of
> coordinate Y (both are supplied from an HTML form).
For such computations, one thing which may be done is to recognize that
squared distance is monotonically related to distance, and may be
interchangeably used with distance for comparison purposes. Thus, one
never needs to actually compute the distance, just the squared distance,
which saves one a repetitive square root computation. There may be
other monotonic relationships in the calculations involving longitude
and latitude which can be similarly exploited for efficiency.
> 2. The nearest X points to coordinate Y (again, supplied by a form).
>
> The first should be simple enough... I already know how to measure the
> distance between two points (once I translate all that trig into perl) so
> all I need to do is run the query and discard any result that's outside the
> circle. The second is tougher. Does anyone know how to sort a list like
> that?
The conceptually simple thing would be to compute a list of all the
squared distances from coordinate Y to all your points (note that you
*will* have to consider each and every possible distance before you can
assure yourself you have the correct X elements), sort an index to the
list in ascending squared-distance order, and pick off the first X
indexed elements. The sort, however, will be O(n*log(n)), and it would
be possible to pick off the smallest X numbers of the list in an O(n)
computation -- if nothing else, by determining the minimum of the list,
removing that, determining the minimum of the remaining list, etc
repeated X times. Or one could start with the first X elements,
determine the maximum of them, then compare the rest of the elements
with that maximum. If a point is lower than that maximum, the old
maximum point is removed from the list of X points, the new element is
added, and a new maximum of the X values is determined. When one gets
to the end of the list, one will have the X smallest elements of the
list. Perl's sort(), however, is so efficient that you might find it
will be faster for a mere 32000-element list. Consider the "Schwartzian
Transform" for implementing the sort.
...
> Ian
HTH.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Wed, 17 Dec 2003 13:39:26 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Return all points with x km of y
Message-Id: <1827589.p7hrWbV6h4@gregs-web-hosting-and-pickle-farming>
It was a dark and stormy night, and Ian Pattison managed to scribble:
> Hi,
>
> I'm trying to put together what I think is a fairly complex database
> query.
>
> I have a table of about 32,000 latitiude and longitude pairs and I need to
> be able to query for two different things:
>
> 1. All points that are within X kilometers (or miles for that matter) of
> coordinate Y (both are supplied from an HTML form).
> 2. The nearest X points to coordinate Y (again, supplied by a form).
>
> The first should be simple enough... I already know how to measure the
> distance between two points (once I translate all that trig into perl) so
> all I need to do is run the query and discard any result that's outside
> the circle. The second is tougher. Does anyone know how to sort a list
> like that?
>
> Thanks,
>
> Ian
I've worked in the area of spatial inxexing in the past. There is a vast scientific literature on storing & retrieving spatial/cadastral information.
Here's a few notes on you question.
1. To do the exact calculation of distance given lat & long requires spherical trigonometry. Over small distances, you can get good local approximate results by knowing the numbeer of km for each unit of latitude & longiture. This varies over the earths surface.
2. To get the poiints within X kilometers, the simplest algorithm has two parts.
2a. First, get all points within a rectangle X km. A simple way to do this in sql is select * from table where lat between 999.999 and 999.999 and long between 999.999 and 999.999
2b. From this subset, use the algorithm in 1.
Unforfunately this is a linear algorithm.
3. There are data structures that solve these problems quickly, like R-trees
http://www.cs.ucr.edu/~marioh/spatialindex/
gtoomey
------------------------------
Date: Wed, 17 Dec 2003 13:49:29 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Return all points with x km of y
Message-Id: <1622521.8o0kvDYArv@gregs-web-hosting-and-pickle-farming>
It was a dark and stormy night, and Bob Walton managed to scribble:
> Ian Pattison wrote:
>
>> Hi,
>>
>> I'm trying to put together what I think is a fairly complex database
>> query.
>
>
> Question about your terminology: by the term "database query", do you
> mean something written in SQL requesting data from a relational
> database? That is what that term generally means to computer
> programmers. I'm no SQL expert, but queries of the form you mention are
> generally not SQL-ish things. So I'll assume your "database" is
> something more like a flat file consisting of two numbers per record.
>
>
You can do it in SQL, and its often done with quadtrees, which is a method of subdividiing down an image into smaller "quardrangles" or "quarters". You can then represent the hirearchy of these images in base 4 arithmetic.
Then each image can be represented by base 4 numbers, which as stored in a database.
You can then improve the time complexity of common operations like proximity, point-in-polygon by querying the database.
Also see the mysql spatial operations.
http://www.mysql.com/doc/en/Spatial_extensions_in_MySQL.html
gtoomey
------------------------------
Date: Wed, 17 Dec 2003 09:35:03 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Return all points with x km of y
Message-Id: <brp807$1lee$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Gregory Toomey
<nospam@bigpond.com>], who wrote in article <1827589.p7hrWbV6h4@gregs-web-hosting-and-pickle-farming>:
> 1. To do the exact calculation of distance given lat & long requires
spherical trigonometry. Over small distances, you can get good
local approximate results by knowing the numbeer of km for each
unit of latitude & longiture. This varies over the earths
surface.
Bulls. First of all, the "distance along surface" can be easily
calculated given the "distance along straight tunnel". To find the
latter, one just needs to recalculate from spherical coordinates to
(x,y.z)-rectangular coordinates: 2 cosines and 2 sines per point.
> 2. To get the poiints within X kilometers
Points within the given distance are within a "spherical hat"; in
other words, they are given by inequality
Ax+By+Cz >= const
Here (A,B,C) are coordinates of the "center", (x,y.z) are coordinates
of the otehr point, and const is easily calculatable.
Hope this helps,
Ilya
------------------------------
Date: 17 Dec 2003 01:56:07 -0800
From: logic1@esatclear.ie (logic1)
Subject: Simple text file operation
Message-Id: <6e20e34b.0312170156.e28636e@posting.google.com>
Guys I have a bit of an issue.
I collect a series of text files on a daily basis. About 48 in total
per day.
The naming format on these files is "<date>_<version_num>_AT*<1 to
10>_asc.blob"
The contents are in the two column format:
---------------------------------------
referencenumber | value
referencenumber | value
referencenumber | value
referencenumber | value
referencenumber | value
---------------------------------------
I need to alter these text files to include two new columns from the
filename itself.
So the file looks like: (Both date and version_num are taken from the
filename and put into the text file)
-------------------------------------------------------------
date | version_num | referencenumber | Value
date | version_num | referencenumber | Value
date | version_num | referencenumber | Value
date | version_num | referencenumber | Value
date | version_num | referencenumber | Value
--------------------------------------------------------------
Any help appreciated.
.logic.
------------------------------
Date: 17 Dec 2003 10:03:16 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Simple text file operation
Message-Id: <brp9l4$a00$1@mamenchi.zrz.TU-Berlin.DE>
logic1 <logic1@esatclear.ie> wrote in comp.lang.perl.misc:
> Guys I have a bit of an issue.
>
> I collect a series of text files on a daily basis. About 48 in total
> per day.
>
> The naming format on these files is "<date>_<version_num>_AT*<1 to
> 10>_asc.blob"
>
> The contents are in the two column format:
>
> ---------------------------------------
> referencenumber | value
> referencenumber | value
> referencenumber | value
> referencenumber | value
> referencenumber | value
> ---------------------------------------
>
>
> I need to alter these text files to include two new columns from the
> filename itself.
>
> So the file looks like: (Both date and version_num are taken from the
> filename and put into the text file)
>
> -------------------------------------------------------------
> date | version_num | referencenumber | Value
> date | version_num | referencenumber | Value
> date | version_num | referencenumber | Value
> date | version_num | referencenumber | Value
> date | version_num | referencenumber | Value
> --------------------------------------------------------------
What have you tried so far?
We can help you with a script, but we're not in the habit of writing
complete solutions from scratch.
Anno
------------------------------
Date: Wed, 17 Dec 2003 11:30:15 +0100
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Where do -T warnings go?
Message-Id: <newscache$fub1qh$lj1$1@news.emea.compuware.com>
Hello all,
I ran into this resentful qx($cmd) problem on 5.8.0 in tainted
mode. It took a very long time before I got to figure out it was
a taint issue because I couldn't find the taint warnings back:
not in $?, $!, $@, webserver error log or syslog. Is taint a
special case here?
Thanks,
Koos
--
KP
43rd Law of Computing: "Anything that can go wr
fortune: Segmentation violation -- Core dumped
------------------------------
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.
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 5947
***************************************