[28378] in Perl-Users-Digest
Perl-Users Digest, Issue: 9742 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 19 21:05:54 2006
Date: Tue, 19 Sep 2006 18:05:04 -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 Tue, 19 Sep 2006 Volume: 10 Number: 9742
Today's topics:
array of hashes with a little more... <mikebjunk@gmail.com>
Re: array of hashes with a little more... usenet@DavidFilmer.com
Re: array of hashes with a little more... MikeBeccaria@gmail.com
Re: array of hashes with a little more... <mikebjunk@gmail.com>
Coderef to object methods? <robb@acm.org>
Re: Coderef to object methods? xhoster@gmail.com
Re: Coderef to object methods? <mritty@gmail.com>
Re: Coderef to object methods? <robb@acm.org>
Re: Coderef to object methods? <robb@acm.org>
Re: Coderef to object methods? xhoster@gmail.com
Re: Coderef to object methods? <nobull67@gmail.com>
Re: Coderef to object methods? <robb@acm.org>
Re: Coderef to object methods? (reading news)
Re: Net::Telnet, script exits after connection failure <glex_no-spam@qwest-spam-no.invalid>
Re: Question on download by LWP <mumia.w.18.spam+nospam.usenet@earthlink.net>
Re: Question on download by LWP <sapience@gmail.com>
Re: Question on download by LWP <sapience@gmail.com>
Re: Question on download by LWP <john@castleamber.com>
Re: Question on download by LWP <mgarrish@gmail.com>
Re: Server/client over a network <scottalorda_NOSPAM@libello.com>
Re: where to put dclone <nobull67@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Sep 2006 16:08:06 -0700
From: "mikeybe" <mikebjunk@gmail.com>
Subject: array of hashes with a little more...
Message-Id: <1158707286.836246.215560@k70g2000cwa.googlegroups.com>
OK. I'm having a bear of a time with this. I think the best way to
present this is to describe the data set and then ask someone to help
me figure out HOW to organize the data.
I am writing a program to pull out data from a pipe delimited file that
has library book information (it's a new book list generated from our
library catalog) like this:
isbn|dewey decimal number|title|author
I know how to read the file and break the elements apart etc. The goal
of the program is to create RSS feeds by dewey number. So, an RSS feed
will have books from 000-100, another 100-200 etc. so people can
subscribe to the new books feed by subject. I am making this list
dynamic so I can alter the list and the program will still work. Like
this:
my @deweystring= qw / 000_100 100_200 200_300 300_400 400_500 500_600
600_700 /;
Using that deweystring list, The program will create the rss files
named the same as the elements of that list (ie "000_100.rss") and
populate them with the correct lines of data. I know how to make the
RSS files (xml::rss etc.).
SO...
I am trying to make a data structure to fit properly and can't get the
syntax right:
I want to make a array of a hashes but the array needs to be named from
that list...so, make an array named @000_100 (I know arrays can't start
with numbers...ideas?) that has a hash with keys "Title" "author"
"ISBN" etc.
So I want to make arrays named after the elements found in the
deweystring list (which everyone says should be done with hashes, and
not variable names) and populate the array with hashes of the data
found in the pipe delimited file....and then get the data back out.
I'll spare you from my code so far since this is a pretty straight
forward question...Can someone write some generic code that would do
something like that? I would REALLY appreciate a little guidance.
Thanks,
Mike
------------------------------
Date: 19 Sep 2006 16:59:50 -0700
From: usenet@DavidFilmer.com
Subject: Re: array of hashes with a little more...
Message-Id: <1158710390.042201.260680@d34g2000cwd.googlegroups.com>
mikeybe wrote:
> that list...so, make an array named @000_100 (I know arrays can't start
> with numbers...ideas?)
Don't make them individual arrays - use a hash of arrays. The hash keys
can be named whatever you like.
> So I want to make arrays named after the elements found in the
> deweystring list (which everyone says should be done with hashes, and
> not variable names) and populate the array with hashes of the data
> found in the pipe delimited file....and then get the data back out.
Are you looking for something like this:
#!/usr/bin/perl
use strict; use warnings;
use Data::Dumper;
my %catalog;
$catalog{'000-100'} = [
{'isbn' => '12345', 'dewey' => 'abc123', 'title' => 'foo'},
{'isbn' => '67890', 'dewey' => 'xyz987', 'title' => 'bar'},
];
$catalog{'100-200'} = [
{'isbn' => '77777', 'dewey' => 'ggg777', 'title' => 'baz'},
{'isbn' => '33333', 'dewey' => 'hhh888', 'title' => 'boo'},
];
print Dumper \%catalog;
__END__
--
David Filmer (http://DavidFilmer.com)
------------------------------
Date: 19 Sep 2006 17:58:50 -0700
From: MikeBeccaria@gmail.com
Subject: Re: array of hashes with a little more...
Message-Id: <1158713930.649201.239810@d34g2000cwd.googlegroups.com>
>
> Are you looking for something like this:
YES, exactly...but see below for more details on where I am having
trouble.
>
> #!/usr/bin/perl
> use strict; use warnings;
> use Data::Dumper;
>
> my %catalog;
>
> $catalog{'000-100'} = [
> {'isbn' => '12345', 'dewey' => 'abc123', 'title' => 'foo'},
> {'isbn' => '67890', 'dewey' => 'xyz987', 'title' => 'bar'},
> ];
>
> $catalog{'100-200'} = [
> {'isbn' => '77777', 'dewey' => 'ggg777', 'title' => 'baz'},
> {'isbn' => '33333', 'dewey' => 'hhh888', 'title' => 'boo'},
> ];
>
The data structure is exactly what I want. I just don't know the syntax
to create this structure using variables from within the program... I
have seen the type of structure you list in books and online...However,
I don't have the data ahead of time to put the information in the way
you listed it. It comes from variables and I want it to so when I want
to change it, I only have to edit the deweystring array. I need to
create the hash keys from a variable name (@deweystring), I need to
dynamically analyze each line to determine which hash key it belongs
in...so if a record had a dewey number of 654 it would be determined
that it belongs in the 600-700 hash key array and the data will need to
be added to that array. I know how to, if given dewey number of 657
return the string from @deweystring "600_700"... I don't know how to
then feed the information into the hash key array with that same name
(i.e. $catalog{'600_700'}).
So, in short, I need to know the syntax of (a) creating the hash names
using the deweystring list (i.e. 000_100 100_200 200_300), (b) adding
the data to the hash arrays on the fly, and (c) extracting the data
from them.
Thanks again,
Mike
------------------------------
Date: 19 Sep 2006 18:02:22 -0700
From: "mikeybe" <mikebjunk@gmail.com>
Subject: Re: array of hashes with a little more...
Message-Id: <1158714142.210636.124920@e3g2000cwe.googlegroups.com>
>
> Are you looking for something like this:
YES, exactly. Thanks for the data structure...but see below for more
details on where I am having trouble.
>
> #!/usr/bin/perl
> use strict; use warnings;
> use Data::Dumper;
>
> my %catalog;
>
> $catalog{'000-100'} = [
> {'isbn' => '12345', 'dewey' => 'abc123', 'title' => 'foo'},
> {'isbn' => '67890', 'dewey' => 'xyz987', 'title' => 'bar'},
> ];
>
> $catalog{'100-200'} = [
> {'isbn' => '77777', 'dewey' => 'ggg777', 'title' => 'baz'},
> {'isbn' => '33333', 'dewey' => 'hhh888', 'title' => 'boo'},
> ];
>
The data structure is exactly what I want. I just don't know the syntax
to create this structure using variables from within the program... I
have seen the type of structure you list in books and online...However,
I don't have the data ahead of time to put the information in the way
you listed it. It comes from variables and I want it to so when I want
to change it, I only have to edit the deweystring array. I need to
create the hash keys from a variable name (@deweystring), I need to
dynamically analyze each line to determine which hash key it belongs
in...so if a record had a dewey number of 654 it would be determined
that it belongs in the 600-700 hash key array and the data will need to
be added to that array. I know how to, if given dewey number of 657
return the string from @deweystring "600_700"... I don't know how to
then feed the information into the hash key array with that same name
(i.e. $catalog{'600_700'}).
So, in short, I need to know the syntax of (a) creating the hash names
using the deweystring list (i.e. 000_100 100_200 200_300), (b) adding
the data to the hash arrays on the fly, and (c) extracting the data
from them.
Thanks again,
Mike
------------------------------
Date: 19 Sep 2006 12:09:43 -0700
From: "robb@acm.org" <robb@acm.org>
Subject: Coderef to object methods?
Message-Id: <1158692983.254363.206430@m73g2000cwd.googlegroups.com>
Hi,
I found examples of coderefs to subroutines in Perl Objects, References
and Modules, chapter 6. It goes something like this:
# Assignment
$subroutine_ref = \&subroutine;
# Invocation
$subroutine_ref->( ... );
But what I need is to obtain a reference to an instance method in the
class in which I'm coding. Anybody know what the syntax would look
like?
Thanks,
Robb
------------------------------
Date: 19 Sep 2006 19:21:20 GMT
From: xhoster@gmail.com
Subject: Re: Coderef to object methods?
Message-Id: <20060919152242.878$R7@newsreader.com>
"robb@acm.org" <robb@acm.org> wrote:
> Hi,
>
> I found examples of coderefs to subroutines in Perl Objects, References
> and Modules, chapter 6. It goes something like this:
>
> # Assignment
> $subroutine_ref = \&subroutine;
>
> # Invocation
> $subroutine_ref->( ... );
>
> But what I need is to obtain a reference to an instance method in the
> class in which I'm coding. Anybody know what the syntax would look
> like?
If you are in the class which you are coding, then the method is just
a subroutine, so you take a reference to it the same way you take a
reference to a subroutine.
Otherwise, if you want the object on which to opperate to be enclosed in
the coderef, then maybe a closure is what you want?
my $closure = sub {$object->method(@_)};
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 19 Sep 2006 12:29:25 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Coderef to object methods?
Message-Id: <1158694165.047370.287220@d34g2000cwd.googlegroups.com>
robb@acm.org wrote:
> I found examples of coderefs to subroutines in Perl Objects, References
> and Modules, chapter 6. It goes something like this:
>
> # Assignment
> $subroutine_ref = \&subroutine;
>
> # Invocation
> $subroutine_ref->( ... );
>
> But what I need is to obtain a reference to an instance method in the
> class in which I'm coding. Anybody know what the syntax would look
> like?
What we think of as "object method calls" are really just subroutine
calls with a bit of misdirection and another bit of magic thrown in.
If you have an object $obj of the class MyClass, then saying:
$obj->foo('bar');
is actually translated by Perl into:
MyClass::foo($obj, $bar);
(The "magic" component is inheritance. The arrow notation will
automatically search $obj's inheritance tree for foo() if it can't find
one in MyClass. The standard notation will not)
So if you want a reference to a method, and to be able to call it from
any object, it's pretty straightforward:
my $meth_ref = \&MyClass::foo;
$meth_ref->($obj, $bar);
If, however, you want to be able to store a reference to a method of a
specific given object, it's a little more complicated. As far as I can
remember, you have to use a closure....
[untested]
my $obj_meth_ref = $obj->make_meth_ref();
$obj_meth_ref->('bar');
#within MyClass.pm now...
sub make_meth_ref {
my $obj = shift;
return sub {
$obj->foo(@_);
};
}
Hope this helps point you in the right direction, at least...
Paul Lalli
------------------------------
Date: 19 Sep 2006 12:34:23 -0700
From: "robb@acm.org" <robb@acm.org>
Subject: Re: Coderef to object methods?
Message-Id: <1158694463.372952.46870@m73g2000cwd.googlegroups.com>
xhos...@gmail.com wrote:
> If you are in the class which you are coding, then the method is just
> a subroutine, so you take a reference to it the same way you take a
> reference to a subroutine.
>
> Otherwise, if you want the object on which to opperate to be enclosed in
> the coderef, then maybe a closure is what you want?
Thanks for the reply. I'm not sure if I need a closure. I'm mapping a
list of strings to private methods that I want to invoke. I'd like to
have syntax like this be valid:
# Assignment
my %method_map = ('feature1' => \&_a_private_method);
# Invocation
my $method_ref= $method_map{'feature1'};
$self->$method_ref( $parameter );
Is there some syntax that's close to this that'd work?
------------------------------
Date: 19 Sep 2006 12:41:15 -0700
From: "robb@acm.org" <robb@acm.org>
Subject: Re: Coderef to object methods?
Message-Id: <1158694875.828296.98070@m73g2000cwd.googlegroups.com>
Paul Lalli wrote:
> So if you want a reference to a method, and to be able to call it from
> any object, it's pretty straightforward:
>
> my $meth_ref = \&MyClass::foo;
> $meth_ref->($obj, $bar);
Thanks for the detailed reply. And this example will probably work for
me.
Now, though, I have to decide whether to go this route at all.
Currently, I'm using the method name to do this mapping:
my $method_name = $method_map{$some_user_input};
return $self->$method_name($data);
I looks a little more straightforward to me, than going the coderef way.
------------------------------
Date: 19 Sep 2006 19:43:21 GMT
From: xhoster@gmail.com
Subject: Re: Coderef to object methods?
Message-Id: <20060919154443.115$Rq@newsreader.com>
"robb@acm.org" <robb@acm.org> wrote:
> xhos...@gmail.com wrote:
> > If you are in the class which you are coding, then the method is just
> > a subroutine, so you take a reference to it the same way you take a
> > reference to a subroutine.
> >
> > Otherwise, if you want the object on which to opperate to be enclosed
> > in the coderef, then maybe a closure is what you want?
>
> Thanks for the reply. I'm not sure if I need a closure. I'm mapping a
> list of strings to private methods that I want to invoke. I'd like to
> have syntax like this be valid:
>
> # Assignment
> my %method_map = ('feature1' => \&_a_private_method);
>
> # Invocation
> my $method_ref= $method_map{'feature1'};
> $self->$method_ref( $parameter );
>
> Is there some syntax that's close to this that'd work?
You can use an ordinary string with the name of the method,
or the UNIVERSAL::can method, or just just take a reference to
fully qualified sub.
perl -wle 'package foo; sub bar {print "asfdadsf"}; package main; \
$bar="bar";foo->$bar();'
perl -wle 'package foo; sub bar {print "asfdadsf"}; package main; \
$bar=foo->can("bar");foo->$bar();'
perl -wle 'package foo; sub bar {print "asfdadsf"}; package main; \
$bar=\&foo::bar;foo->$bar();'
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 19 Sep 2006 12:52:45 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: Coderef to object methods?
Message-Id: <1158695565.369814.282510@e3g2000cwe.googlegroups.com>
robb@acm.org wrote:
> xhos...@gmail.com wrote:
> > If you are in the class which you are coding, then the method is just
> > a subroutine, so you take a reference to it the same way you take a
> > reference to a subroutine.
> >
> > Otherwise, if you want the object on which to opperate to be enclosed in
> > the coderef, then maybe a closure is what you want?
>
> Thanks for the reply. I'm not sure if I need a closure. I'm mapping a
> list of strings to private methods that I want to invoke. I'd like to
> have syntax like this be valid:
>
> # Assignment
> my %method_map = ('feature1' => \&_a_private_method);
>
> # Invocation
> my $method_ref= $method_map{'feature1'};
> $self->$method_ref( $parameter );
>
> Is there some syntax that's close to this that'd work?
Er, that exact syntax will work. But method-refs in Perl are only fully
supported as symbolic refs. This is because Perl5's implementation of
object inheritance relies on doing method lookups at runtime using
strings.
If $method_ref is a hard coderef then:
$self->$method_ref( $parameter )
is more or less just another way of saying
$method_ref->( $self, $parameter )
------------------------------
Date: 19 Sep 2006 12:59:09 -0700
From: "robb@acm.org" <robb@acm.org>
Subject: Re: Coderef to object methods?
Message-Id: <1158695949.703978.212460@h48g2000cwc.googlegroups.com>
Brian McCauley wrote:
> Er, that exact syntax will work. But method-refs in Perl are only fully
> supported as symbolic refs. This is because Perl5's implementation of
> object inheritance relies on doing method lookups at runtime using
> strings.
Excellent. So it sounds like I can use this simple syntax, at the
price of not having inheritance supported?
That'd work for me - I'm not using inheritance.
The only problem would be if perl expects inheritance to function -
ie., if there's an implicit parent Object class with important built-in
functionality. (ala Smalltak, Python, Java...) It sounds like this
isn't the case. (?)
------------------------------
Date: Tue, 19 Sep 2006 20:48:30 GMT
From: "Mumia W. (reading news)" <paduille.4058.mumia.w@earthlink.net>
Subject: Re: Coderef to object methods?
Message-Id: <yIYPg.3588$UG4.3509@newsread2.news.pas.earthlink.net>
On 09/19/2006 02:59 PM, robb@acm.org wrote:
> Brian McCauley wrote:
>> Er, that exact syntax will work. But method-refs in Perl are only fully
>> supported as symbolic refs. This is because Perl5's implementation of
>> object inheritance relies on doing method lookups at runtime using
>> strings.
>
> Excellent. So it sounds like I can use this simple syntax, at the
> price of not having inheritance supported?
>
> That'd work for me - I'm not using inheritance.
>
> The only problem would be if perl expects inheritance to function -
> ie., if there's an implicit parent Object class with important built-in
> functionality. (ala Smalltak, Python, Java...) It sounds like this
> isn't the case. (?)
>
The "simple" syntax, $obj->$method(@params), works normally even for
inheritance (if $method is the name of the method as a string).
--
paduille.4058.mumia.w@earthlink.net
------------------------------
Date: Tue, 19 Sep 2006 13:36:09 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Net::Telnet, script exits after connection failure
Message-Id: <451037d4$0$34080$815e3792@news.qwest.net>
--Jani-- wrote:
> Hi all!
>
> I'm trying to make connections (and run several commands) to several
> machines with telnet.pm. Here's the example what my script does:
Net::Telnet
>
> 1. It reads all connection parameters ($ip, $username, $pwd) from
> config-file into an @rray.
> 2. Foreach row (cell) it makes connection to $ip and logs in with
> $username and $pwd.
> 3. It executes several commands, brings output into an @rray or file
> and then exits the connection.
>
> The problem is that if it fails to open connection (peer not respondin,
> bad user etc) it exits the whole program. If I run the program without
> using any telnet.pm funtions everything works fine, for example
> printing variables on each cell of the @rray. So, could someone tell me
> what do I have to change in telnet.pm (or in the way using it) to make
> it work?
Please use English, e.g. 'array' instead of @rray.
Why not show us your code?
To learn how to handle exceptions, see:
perldoc -f eval
Also, see the 'errmode' method in Net::Telnet's documentation. Seems
like you can simply set the mode to 'return'.
------------------------------
Date: Tue, 19 Sep 2006 18:58:11 GMT
From: "Mumia W." <mumia.w.18.spam+nospam.usenet@earthlink.net>
Subject: Re: Question on download by LWP
Message-Id: <75XPg.9713$v%4.1406@newsread1.news.pas.earthlink.net>
On 09/19/2006 10:29 AM, Wonder wrote:
> "John Bokma" <john@castleamber.com> wrote in message
>> You might want to try:
>>
>> my $ua = LWP::UserAgent->new(
>> agent => 'Mozilla/5.0'
>> );
>>
>> If that gives the same problem, try to use a longer agent, e.g.
>>
>> my $ua = LWP::UserAgent->new(
>> agent => 'Mozilla/5.0'
>> . ' (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6)'
>> . ' Gecko/20060728 Firefox/1.5.0.6'
>> );
>>
>> (yes, I am going to update after this post :-) ).
>
> Thanks, John. It seems both methods don't work. I got the same "404 not
> found" error.
> Here is the web page I'd like to access:
> http://0daycheck.eastgame.net/0day/archives/20060901.html
>
>> Quite some sites block well known "grabbers".
>>
>>> $CurrentURL = "http://DomainName.com/RemoteFileName.html";
>> don't use camelcase with Perl (yes, that sounds like a contradiction).
>> Also, RemoteFileName.html is not really a filename Also, use example.com
>> for examples, don't invent domain names.
>>
>
> Sorry, I'm new in this group, and get the habit of camelcase from C++
> programming. It's the first time I heard of the perl_style (shouldn't
> it be like this?). Thank you for letting me know. I'll be very glad to
> conform to it here.
>
> DS: Thank you too for your understanding.
>
> Wonder
>
What does "DS" mean?
I accessed that URL using a few programs, and these are my results:
Firefox 1.5 (works)
wget (fails)
curl (works)
lynx (works)
I got real curious, so I wrote a perl [0] program to download that site.
I'm a dial-up user, so I notice any lags in download time. Usually, a
404 response comes back immediately, but not this time.
For some insane reason, that site outputs a 221 thousand-byte 404 error
response--probably due to webmaster brain-death. The output is largely
in Chinese, and it seems to be some sort of warez page.
I hope this helps. Don't steal any software. YMMV. Be nice to others.
Eat your peas....
--
[0]
use LWP::UserAgent;
use File::Slurp;
my $url = "http://0daycheck.eastgame.net/0day/archives/20060901.html";
unlink '404-out.html';
my $ua = LWP::UserAgent->new();
my $response = $ua->get($url);
if ($response->is_success) {
print $response->content;
} else {
print $response->status_line;
write_file '404-out.html', $response->content;
}
------------------------------
Date: 19 Sep 2006 13:07:39 -0700
From: "Wonder" <sapience@gmail.com>
Subject: Re: Question on download by LWP
Message-Id: <1158696459.194992.18720@b28g2000cwb.googlegroups.com>
Mumia W. wrote:
>
> What does "DS" mean?
>
> I accessed that URL using a few programs, and these are my results:
>
> Firefox 1.5 (works)
> wget (fails)
> curl (works)
> lynx (works)
>
> I got real curious, so I wrote a perl [0] program to download that site.
> I'm a dial-up user, so I notice any lags in download time. Usually, a
> 404 response comes back immediately, but not this time.
>
> For some insane reason, that site outputs a 221 thousand-byte 404 error
> response--probably due to webmaster brain-death. The output is largely
> in Chinese, and it seems to be some sort of warez page.
>
> I hope this helps. Don't steal any software. YMMV. Be nice to others.
> Eat your peas....
>
> --
Thanks, Mumia. DS is the initial of a guy who took part in the
discussion yesterday.
Yeah, this is a website about warez, but it only briefly introduces
what those software are. It doesn't supply any downloads. I would just
download the html file and fetch the links of some pictures, so from my
understanding, it is legal.
> [0]
> use LWP::UserAgent;
> use File::Slurp;
> my $url = "http://0daycheck.eastgame.net/0day/archives/20060901.html";
> unlink '404-out.html';
>
> my $ua = LWP::UserAgent->new();
> my $response = $ua->get($url);
> if ($response->is_success) {
> print $response->content;
> } else {
> print $response->status_line;
> write_file '404-out.html', $response->content;
> }
------------------------------
Date: 19 Sep 2006 13:20:44 -0700
From: "Wonder" <sapience@gmail.com>
Subject: Re: Question on download by LWP
Message-Id: <1158697243.933690.185270@k70g2000cwa.googlegroups.com>
John Bokma wrote:
> http://0daycheck.eastgame.net/0day/archives/20060901.html
>
> GET /0day/archives/20060901.html HTTP/1.1
> Host: 0daycheck.eastgame.net
> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7)
> Gecko/20060909 Firefox/1.5.0.7
> Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=
> 0.9,text/plain;q=0.8,image/png,*/*;q=0.5
> Accept-Language: en-us,en;q=0.5
> Accept-Encoding: gzip,deflate
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> Keep-Alive: 300
> Connection: keep-alive
>
> HTTP/1.x 404 Not Found
> Server: Zeus/4.3
> Date: Tue, 19 Sep 2006 17:39:10 GMT
> Content-Type: text/html
> X-Cache: MISS from cache.xal.megared.net.mx
> Connection: close
>
>
> So, yeah, they return a 404 :-) (output via Firefox + live headers
> extension).
>
> use strict;
> use warnings;
>
> use LWP::UserAgent;
>
> my $ua = LWP::UserAgent->new();
>
> my $url = 'http://0daycheck.eastgame.net/0day/archives/20060901.html';
> my $response = $ua->get( $url );
>
> $response->is_success
> or $response->code == 404 # ignore 404
> or die "Can't get '$url': ", $response->status_line;
>
> print $response->content;
>
>
> --
> John Experienced Perl programmer: http://castleamber.com/
>
> Perl help, tutorials, and examples: http://johnbokma.com/perl/
Thanks a lot, John. The webpage is in $response->content. So, I'm
curious how the browser knows it's not a real 404 error, and know to
display the real content instead of an 404 error.
Besides, this is probably a silly question: if I put quotation marks
around the $response member variables, such as
print "$response->content";
I'll get a line "HTTP::Response=HASH(0x104832bc)->content". Why is
that?
Thanks.
Wonder
------------------------------
Date: 19 Sep 2006 22:05:08 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Question on download by LWP
Message-Id: <Xns9843ADCD9A060castleamber@130.133.1.4>
"Wonder" <sapience@gmail.com> wrote:
> print "$response->content";
>
> I'll get a line "HTTP::Response=HASH(0x104832bc)->content". Why is
> that?
You might want to read:
perldoc perlintro (Basic syntax overview, print)
perldoc perlboot (which explains why $response "contains"
HTTP::Response=HASH(...)
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: 19 Sep 2006 16:16:53 -0700
From: "Matt Garrish" <mgarrish@gmail.com>
Subject: Re: Question on download by LWP
Message-Id: <1158707812.863238.212420@e3g2000cwe.googlegroups.com>
David Squire wrote:
> John Bokma wrote:
> > David Squire <David.Squire@no.spam.from.here.au> wrote:
> >
> >> John Bokma wrote:
> >>
> >>> don't use camelcase with Perl
> >> Now, familiar as I am with the doctrinaire nature of this group, this
> >> seems to me to go too far. Surely folk can have their own naming
> >> conventions and you (we) can be quiet about that.
> >
> > Yup, as they can decide not to use strict & warnings. Yet this group
> > insists on some form of readability, and *I* include not using camel case
> > with that.
>
> I can't agree with this. Using strict and warnings is language-specific
> advice that helps folk solve and avoid problems. The readability or not
> of "camelcase" is person-specific and has nothing to do with Perl.
>
> So, I have no problems with your saying "I don't like camelcase", but
> "don't use camelcase with Perl" to me over-steps the mark.
>
> I, and no doubt others, participate in multiple Perl projects where we
> don't always have control over naming conventions (how do you feel about
> Hungarian?), and editing that down should surely not be a requirement
> for posting here.
Don't forget those of us who can't type worth a damn. It's enough just
to get me to use the shift key, but to also try and reach the
underscore key is asking too much. And besides, what gets called "camel
case" here is standard coding convention for almost all the other
languages I have to deal in. It certainly doesn't warrant chastising a
poster about, because as you note, it is just style and I'm sure we've
all used it.
Matt
------------------------------
Date: Tue, 19 Sep 2006 21:02:23 +0200
From: =?ISO-8859-1?Q?S=E9bastien_Cottalorda?= <scottalorda_NOSPAM@libello.com>
Subject: Re: Server/client over a network
Message-Id: <45103ec0$0$281$626a54ce@news.free.fr>
deadpickle a écrit :
> what I want to do is have a server on one machine and a client on the
> other. I want the client to connect to the server through a tcp network
> (over the internet). I have tried this and I constantly get the no
> socket error.
Hi,
On which side : client or server ?
If it's on the client side, you cannot manage to reach the server socket
through the router.
Try this:
#> telnet router 7890
that will try open a telnet session on the router port 7890
If your router forward this port, your request will go to the server on
which you want to pick the file.
Just enter FIL|namefile
Normaly you'll see something
NOTE: your client socket need to be open with the *router* and not with
the server (port forwarding case).
If you mean routing instead of port forwarding, then the client needs to
point to the *server* adress.
> The program works on the local machine just fine. Also I
> am going trough a router but I did forward the ports. Is there
> something I need to do to the code? Am I entering the correct values?
It seems to be network problem.
Sebastien
------------------------------
Date: 19 Sep 2006 12:56:32 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: where to put dclone
Message-Id: <1158695792.288793.239860@i3g2000cwc.googlegroups.com>
J. Gleixner wrote:
> Brian McCauley wrote:
> > Graham Wood wrote:
> >> my @paths, @missing;
> > No, there's nothing wrong there[...]
> Except for:
>
> >> my @paths, @missing;
>
> Graham, add the following to your code, to point out the issue with that
> line.
>
> use strict;
> use warnings;
D'oh!
------------------------------
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 9742
***************************************