[23364] in Perl-Users-Digest
Perl-Users Digest, Issue: 5583 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 29 09:05:53 2003
Date: Mon, 29 Sep 2003 06:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 29 Sep 2003 Volume: 10 Number: 5583
Today's topics:
Re: A couple of hash questions <noreply@gunnar.cc>
Re: A couple of hash questions <dave.nospam@ntlworld.com>
LWP::Simple get() problem <Hon.Lee@Sun.COM>
LWP::Simple get() refined problem <Hon.Lee@Sun.COM>
Re: LWP::Simple get() refined problem <kurzhalsflasche@yahoo.co.uk>
Re: New FAQ: How do I compute the difference of two arr (Anno Siegel)
Re: Uploading files using CGI.pm <flavell@ph.gla.ac.uk>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 29 Sep 2003 12:10:09 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: A couple of hash questions
Message-Id: <bl90df$9ki95$1@ID-184292.news.uni-berlin.de>
Dave Saville wrote:
> On Mon, 29 Sep 2003 06:57:18 +0200, Gunnar Hjalmarsson wrote:
>> I have never used Storable, but I'm storing a few small hashes in
>> SDBM files. I have never benchmarked, but it seems to be more
>> durable than plain text files, and the minimum size of an SDBM
>> database is just 1 kiB.
>>
>> What is it that makes you say it would be overkill?
>
> I am only talking a couple of thousand pairs - and I don't have a
> DB installed - at least not on this box and in any case I might be
> releasing the code to a few friends and I can be sure they won't -
> a plain file or a perl internal type file would be portable code.
Simple DBM files (SDBM) are portable, at least between *nix and
Windows platforms. SDBM_File.pm, which gives you tied access to such
files, comes with Perl, and does not require any separate database
program.
I'm not saying it's better, but I still believe it would be an
alternative to you.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 29 Sep 2003 12:35:30 +0100 (BST)
From: "Dave Saville" <dave.nospam@ntlworld.com>
Subject: Re: A couple of hash questions
Message-Id: <qnirfnivyyragyjbeyqpbz.hlzi366.pminews@text.news.ntlworld.com>
On Mon, 29 Sep 2003 12:10:09 +0200, Gunnar Hjalmarsson wrote:
>Simple DBM files (SDBM) are portable, at least between *nix and
>Windows platforms. SDBM_File.pm, which gives you tied access to such
>files, comes with Perl, and does not require any separate database
>program.
>
>I'm not saying it's better, but I still believe it would be an
>alternative to you.
OK I will look into it. Thanks.
Regards
Dave Saville
NB switch saville for nospam in address
------------------------------
Date: Mon, 29 Sep 2003 12:10:13 +0100
From: Hon Guin Lee - Web Producer - SMI Marketing <Hon.Lee@Sun.COM>
Subject: LWP::Simple get() problem
Message-Id: <3F781315.A48F140A@Sun.COM>
Hi All,
I am having a problem that the LWP get() function cannot retrieve unlocalised content that begins with www from the specified URL entered on the web form I created. Using Mozilla 1.1, it just cannot retrieve the web document (hence it fails and returns undef - within the subroutine get_url), but for localised web content on the local web server, it can retrieve most web documents with no problem.
Looking at the problem at a different perspective, I used other functions such as getstore(url,file) and mirror(url,file) where url is replaced with shift and a specified filename, the LWP::Debug just throws up some internal server errors displayed on the web browser requiring some a proxy: -
--------------------------------------------------------------------------
LWP::UserAgent::new: () LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/redirect.jsp LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 57 bytes LWP::UserAgent::request: Simple response:
Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/location.jsp LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 19 bytes LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/redirect.jsp?location=Non-US LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 57
bytes LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/cachedir/cachedtab_Non-US_NEWS.html LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::UserAgent::request: Simple response: Internal Server Error 500
-- This is for a localised URL.
--------------------------------------------------------------------------
LWP::UserAgent::new: () LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://www.sun.com LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::UserAgent::request: Simple response: Internal Server Error 500
-- This is for a URL that begins with www.
--------------------------------------------------------------------------
Here is the script: -
#!/usr/local/perl5.6/bin/perl -wT
# perl script to get remote
# urls and strip them and
# upload them to teamsite
use LWP::Simple qw(!head);
use LWP::Debug '+';
use CGI qw(:standard); # then only CGI.pm defines a head()
use strict;
print "Content-type: text/html\n\n";
my $old_handle;
$|++; #sets $| for STDOUT
$old_handle = select( STDERR ); #change to STDERR
$|++; #sets $| for STDERR
select( $old_handle ); #change back to STDOUT
my ($url) = @_;
my $lang;
process_form();
get_url($url);
# Passes the data from the server,
# and takes them onto the PERL script.
sub process_form {
$url = param('url');
$url = "http://$url";
$lang = param('lang');
}
# Retrieves the contents of the
# specified URL.
sub get_url {
my $page = getstore(shift,'hon.html');
unless (defined $page) {
print "Couldn't retrieve $url";
}
else {
print "$page\n";
}
}
----------------------------------------------------------------------
Are there any problems/reasons why the get() function does not retrieve unlocalised web content that doesn't start with www?
Thanks.
------------------------------
Date: Mon, 29 Sep 2003 11:51:50 +0100
From: Hon Guin Lee - Web Producer - SMI Marketing <Hon.Lee@Sun.COM>
Subject: LWP::Simple get() refined problem
Message-Id: <3F780EC6.502A5C10@Sun.COM>
Hi all,
The LWP::get() function manages to retrieve some of the localised web document content from local web servers displayed on my web browser using Mozilla 1.1, for URL's without the www.
However for URLs that begin with www, the get() functon just returns an undef (shown in subroutine get_url) hence the web browser unables to display the web content.
To narrow the problem further, I used some of the other functions such as getstore(url,file) and mirror(url,file) where I replace url with shift, and a filename specified, but the LWP::Debug just throws up: -
--------------------------------------------------------------------------
LWP::UserAgent::new: () LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/redirect.jsp LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 57 bytes LWP::UserAgent::request: Simple response:
Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/location.jsp LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 19 bytes LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/redirect.jsp?location=Non-US LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 57
bytes LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/cachedir/cachedtab_Non-US_NEWS.html LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::UserAgent::request: Simple response: Internal Server Error 500
--This is a URL specifed for the local web server requesting some form of proxy.
--------------------------------------------------------------------------
LWP::UserAgent::new: () LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://www.sun.com LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::UserAgent::request: Simple response: Internal Server Error 500
--This is a URL specified for a www web docuument.
--------------------------------------------------------------------------
Any solutions/reasons why the get() function cannot retrieve unlocalised web content?
Here is the script: -
--------------------------------------------------------------------------
#!/usr/local/perl5.6/bin/perl -wT
# perl script to get remote
# urls and strip them and
# upload them to teamsite
use LWP::Simple qw(!head);
use LWP::Debug '+';
use CGI qw(:standard); # then only CGI.pm defines a head()
use strict;
print "Content-type: text/html\n\n";
my $old_handle;
$|++; #sets $| for STDOUT
$old_handle = select( STDERR ); #change to STDERR
$|++; #sets $| for STDERR
select( $old_handle ); #change back to STDOUT
my ($url) = @_;
my $lang;
process_form();
get_url($url);
# Passes the data from the server,
# and takes them onto the PERL script.
sub process_form {
$url = param('url');
$url = "http://$url";
$lang = param('lang');
}
# Retrieves the contents of the
# specified URL.
sub get_url {
my $page = get(shift);
unless (defined $page) {
print "Couldn't retrieve $url";
}
else {
print "$page\n";
}
}
--------------------------------------------------------------------------
------------------------------
Date: Mon, 29 Sep 2003 13:14:52 +0200
From: Dominik Seelow <kurzhalsflasche@yahoo.co.uk>
Subject: Re: LWP::Simple get() refined problem
Message-Id: <bl944g$9iuup$1@uni-berlin.de>
Hon Guin Lee - Web Producer - SMI Marketing wrote:
> Hi all,
>
> The LWP::get() function manages to retrieve some of the localised web document content from local web servers displayed on my web browser using Mozilla 1.1, for URL's without the www.
> However for URLs that begin with www, the get() functon just returns an undef (shown in subroutine get_url) hence the web browser unables to display the web content.
>
> To narrow the problem further, I used some of the other functions such as getstore(url,file) and mirror(url,file) where I replace url with shift, and a filename specified, but the LWP::Debug just throws up: -
>
> --------------------------------------------------------------------------
>
> LWP::UserAgent::new: () LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/redirect.jsp LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 57 bytes LWP::UserAgent::request: Simple response:
> Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/location.jsp LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 19 bytes LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/redirect.jsp?location=Non-US LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 57
> bytes LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://sunweb.central.sun.com/cachedir/cachedtab_Non-US_NEWS.html LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::UserAgent::request: Simple response: Internal Server Error 500
>
> --This is a URL specifed for the local web server requesting some form of proxy.
>
> --------------------------------------------------------------------------
>
> LWP::UserAgent::new: () LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://www.sun.com LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::UserAgent::request: Simple response: Internal Server Error 500
>
> --This is a URL specified for a www web docuument.
>
> --------------------------------------------------------------------------
>
> Any solutions/reasons why the get() function cannot retrieve unlocalised web content?
>
> Here is the script: -
>
> --------------------------------------------------------------------------
>
> #!/usr/local/perl5.6/bin/perl -wT
>
> # perl script to get remote
> # urls and strip them and
> # upload them to teamsite
>
> use LWP::Simple qw(!head);
> use LWP::Debug '+';
> use CGI qw(:standard); # then only CGI.pm defines a head()
> use strict;
>
> print "Content-type: text/html\n\n";
>
> my $old_handle;
>
> $|++; #sets $| for STDOUT
> $old_handle = select( STDERR ); #change to STDERR
> $|++; #sets $| for STDERR
> select( $old_handle ); #change back to STDOUT
>
> my ($url) = @_;
> my $lang;
>
> process_form();
> get_url($url);
>
> # Passes the data from the server,
> # and takes them onto the PERL script.
>
> sub process_form {
>
> $url = param('url');
> $url = "http://$url";
> $lang = param('lang');
>
> }
>
> # Retrieves the contents of the
> # specified URL.
>
> sub get_url {
>
> my $page = get(shift);
>
> unless (defined $page) {
> print "Couldn't retrieve $url";
> }
> else {
> print "$page\n";
> }
>
> }
> --------------------------------------------------------------------------
Do you use a proxy to display web content from outside when using your
browser?
perldoc LWP says:
ENVIRONMENT
The following environment variables are used by LWP:
<snip>
http_proxy
ftp_proxy
xxx_proxy
no_proxy
These environment variables can be set to enable communication
through a proxy server. See the description of the "env_proxy"
method in LWP::UserAgent.
It /might/ help to specify a proxy server.
Good luck,
Dominik
------------------------------
Date: 29 Sep 2003 10:33:07 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: New FAQ: How do I compute the difference of two arrays?
Message-Id: <bl91p3$o3l$1@mamenchi.zrz.TU-Berlin.DE>
Gregory Toomey <nospam@bigpond.com> wrote in comp.lang.perl.misc:
> It was a dark and stormy night, and Randal L. Schwartz managed to scribble:
>
> >>>>>> "The" == The Poor <a@job.mx.2y.net> writes:
> >
> > The> -
> > The> New:
> > The> +
> > The> How do I compute the difference of two arrays? How do I compute
> > the The> intersection of two arrays?
> >
> > The> Use a hash. Here's code to do both and more. It assumes that each
> > The> element is unique in a given array:
> >
> > Here's code that doesn't require that uniqueness, and would be a better
> > candidate for the FAQ:
> >
> > my %tally;
> > $tally{$_} .= "a" for @array_a;
> > $tally{$_} .= "b" for @array_b;
> > my @union = keys %tally;
> > my @intersection = grep $tally{$_} =~ /ab/, @union;
> > my @a_not_b = grep $tally{$_} =~ /a$/, @union;
> > my @b_not_a = grep $tally{$_} =~ /^b/, @union;
> >
> > print "Just another Perl hacker,";
>
> Having coded this problem myself, your solution is minimal & very
> elegant (as expected).
...a variation on the theme:
my %tally;
$tally{$_} += 1 for @array_a; # or |=
$tally{$_} += 2 for @array_b;
# use more powers of two for more arrays
my @union = keys %tally;
my @intersection = grep $tally{$_} == 3, @union;
my $a_not_b = grep $tally{$_} == 1, @union;
my $b_not_a = grep $tally{$_} == 2, @union;
# etc.
Anno
------------------------------
Date: Mon, 29 Sep 2003 11:26:03 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Uploading files using CGI.pm
Message-Id: <Pine.LNX.4.53.0309291121170.7040@ppepc56.ph.gla.ac.uk>
On Mon, 29 Sep 2003, James Willmore wrote:
> use strict should be in your code.
good advice
> Have you checked the error log for the server? Are you sure you can
> upload files?
Did you look at the code which the hon Usenaut provided? Seems to me
that the open was for writing, it correctly tested the result of the
open, it would have reported the results of an error correctly.
Seems to me it probably successfully opened a file somewhere, and
uploaded the data to it. Just that it wasn't where the hon Usenaut
looked for it, due to failing to specify its absolute filepath and not
knowing where the current working directory was at the time (this is
_NOT_ regulated by the CGI spec).
> ... and also need to consider posting to a CGI authoring group.
Yup.
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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 5583
***************************************