[30805] in Perl-Users-Digest
Perl-Users Digest, Issue: 2050 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 12 00:09:46 2008
Date: Thu, 11 Dec 2008 21:09:10 -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, 11 Dec 2008 Volume: 11 Number: 2050
Today's topics:
Re: Are file scoped variables in a module duplicated wi sln@netherlands.com
I need help with PDF::API2 to make a PDF file navigatio <r.ted.byers@gmail.com>
Is there a port of Perl for Win* platforms? <nospam-abuse@ilyaz.org>
Re: Is there a port of Perl for Win* platforms? <1usa@llenroc.ude.invalid>
Re: Is there a port of Perl for Win* platforms? <tim@burlyhost.com>
Re: Is there a port of Perl for Win* platforms? <jurgenex@hotmail.com>
Re: Mathematica 7 compares to other languages <jon@ffconsultancy.com>
Re: Processing Multiple Large Files <peter@makholm.net>
Re: Processing Multiple Large Files <RedGrittyBrick@spamweary.invalid>
Re: Processing Multiple Large Files <1usa@llenroc.ude.invalid>
Re: querying Active Directory via LDAP in perl <nospam@somewhere.com>
Re: The single biggest STUPIDITY in Perl ... <jpsweden@gmail.com>
Re: The single biggest STUPIDITY in Perl ... <jpsweden@gmail.com>
Re: The single biggest STUPIDITY in Perl ... <uri@stemsystems.com>
Re: The single biggest STUPIDITY in Perl ... <tadmc@seesig.invalid>
Re: Trouble with Net::Ping <r.ted.byers@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 11 Dec 2008 22:32:29 GMT
From: sln@netherlands.com
Subject: Re: Are file scoped variables in a module duplicated with each class instantiation?
Message-Id: <b753k4dqhsmrtpfnocn3acf1m5gvm7pum5@4ax.com>
Thank you!
sln
------------------------------
Date: Thu, 11 Dec 2008 14:30:17 -0800 (PST)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: I need help with PDF::API2 to make a PDF file navigation aide
Message-Id: <9468d271-3cf7-4e05-9928-aec536e922ea@o40g2000prn.googlegroups.com>
I have used this, along with a couple other of the PDF modules, to
create what are now rather large PDF files. They are a bit tedious to
scroll through, so what I want to do now is create something like a
table of contents that is always displayed in a narrow strip along the
left margin that allows the reader to simply select an item in that
window and have the corresponding page appear in the main window. But
unlike a conventional table of contents, it would never appear at the
beginning of the document in the main window (and unlike an index, it
would never appear at the end of the document).
What is the normal term for this 'object' in the PDF documentation?
How do I create it (or is it always present even if not visible, in a
PDF file created by new('filename.pdf')), and how do I specify that
this page, but not that page, should be linked to it with this title?
Thanks
Ted
------------------------------
Date: Fri, 12 Dec 2008 01:22:23 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Is there a port of Perl for Win* platforms?
Message-Id: <ghsecf$1vij$1@agate.berkeley.edu>
Is there a port of Perl for Win* platforms? The minimal functionality
required is to read @ARGV, open() files for read and write, and get a
directory listing.
Thanks,
Ilya
P.S. I carry ActiveState port on a memory stick (age = couple of
years), but it is not able to do any of these...
------------------------------
Date: Fri, 12 Dec 2008 02:31:34 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Is there a port of Perl for Win* platforms?
Message-Id: <Xns9B71DAF97CCABasu1cornelledu@127.0.0.1>
Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote in news:ghsecf$1vij$1
@agate.berkeley.edu:
> Is there a port of Perl for Win* platforms? The minimal functionality
> required is to read @ARGV, open() files for read and write, and get a
> directory listing.
...
> P.S. I carry ActiveState port on a memory stick (age = couple of
> years), but it is not able to do any of these...
I mostly use the AS port and have done so since I started learning Perl.
Every AS Perl version I have used has been able to do what you say you
want:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
print Dumper \@ARGV;
for my $f (@ARGV) {
open my $h, '>', $f
or die "Cannot open '$f': $!";
print $h "$f\n";
close $h
or die "Cannot close '$f': $!";
}
for my $f (@ARGV) {
open my $h, '<', $f
or die "Cannot open '$f': $!";
print scalar <$h>;
close $h
or die "Cannot close '$f': $!";
}
opendir my $d, '.'
or die "Cannot open current directory: $!";
print map { "$_\n" } sort readdir $d;
closedir $d;
__END__
C:\DOCUME~1\asu1\LOCALS~1\Temp\t> t 1 2 3 4 5
$VAR1 = [
'1',
'2',
'3',
'4',
'5'
];
1
2
3
4
5
.
..
1
2
3
4
5
t.pl
C:\DOCUME~1\asu1\LOCALS~1\Temp\t> perl -v
This is perl, v5.10.0 built for MSWin32-x86-multi-thread
(with 5 registered patches, see perl -V for more detail)
Copyright 1987-2007, Larry Wall
Binary build 1004 [287188] provided by ActiveState
http://www.ActiveState.com
Built Sep 3 2008 13:16:37
C:\DOCUME~1\asu1\LOCALS~1\Temp\t> ver
Microsoft Windows XP [Version 5.1.2600]
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
------------------------------
Date: Thu, 11 Dec 2008 20:30:52 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: Is there a port of Perl for Win* platforms?
Message-Id: <0Ol0l.17113$4f3.10663@newsfe14.iad>
Ilya Zakharevich wrote:
> Is there a port of Perl for Win* platforms? The minimal functionality
> required is to read @ARGV, open() files for read and write, and get a
> directory listing.
>
> Thanks,
> Ilya
>
> P.S. I carry ActiveState port on a memory stick (age = couple of
> years), but it is not able to do any of these...
I've not used a Win system for many years, but I used to develop on
WinNT, Linux and FreeBSD systems for Perl scripts and used ActiveState
Perl on the WinNT box, and my scripts very often needed to do these
things and I don't recall every having such experiences. If there are
any errors or warnings, perhaps it's due to the system itself?
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Thu, 11 Dec 2008 20:39:22 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Is there a port of Perl for Win* platforms?
Message-Id: <pgq3k41qo1p3ob3acsn4ett63khroka621@4ax.com>
Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
>Is there a port of Perl for Win* platforms?
I have never heard of Win*.
However, if you are referring to Microsoft WIndows then yes, there are a
few. The most popular is probably Active State Perl, which is free and
can be downloaded from their web site.
>The minimal functionality
>required is to read @ARGV, open() files for read and write, and get a
>directory listing.
AS Perl is fully functional, supports a large variaty of modules and -as
long as they are pure Perl- even more can be installed directly from
CPAN, too.
>P.S. I carry ActiveState port on a memory stick (age = couple of
> years), but it is not able to do any of these...
Any version of AS that I am aware of, even ancient onces, will do those
tasks without any problems. Your issues must have some other reason.
jue
------------------------------
Date: Thu, 11 Dec 2008 22:57:45 +0000
From: Jon Harrop <jon@ffconsultancy.com>
Subject: Re: Mathematica 7 compares to other languages
Message-Id: <S_adnUFJfP3bB9zUnZ2dnUVZ8sPinZ2d@posted.plusnet>
Xah Lee wrote:
> On Dec 10, 2:47Â pm, John W Kennedy <jwke...@attglobal.net> wrote:
>> Xah Lee wrote:
>> > In lisp, python, perl, etc, you'll have 10 or so lines. In C or Java,
>> > you'll have 50 or hundreds lines.
>>
>> C:
>>
>> #include <stdlib.h>
>> #include <math.h>
>>
>> void normal(int dim, float* x, float* a) {
>> float sum = 0.0f;
>> int i;
>> float divisor;
>> for (i = 0; i < dim; ++i) sum += x[i] * x[i];
>> divisor = sqrt(sum);
>> for (i = 0; i < dim; ++i) a[i] = x[i]/divisor;
>>
>> }
>
> i don't have experience coding C. The code above doesn't seems to
> satisfy the spec. The input should be just a vector, array, list, or
> whatever the lang supports.
> The output is the same datatype of the same dimension.
The output is in the preallocated argument "a". It is the same type (float
*) and has the same dimension. That is idiomatic C.
You could define a struct type representing a vector that includes its
length and data (akin to std::vector<..> in C++) but it would still be
nowhere near 50 LOC as you claimed.
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?u
------------------------------
Date: Thu, 11 Dec 2008 22:13:03 +0100
From: Peter Makholm <peter@makholm.net>
Subject: Re: Processing Multiple Large Files
Message-Id: <87oczixvog.fsf@vps1.hacking.dk>
"friend.05@gmail.com" <hirenshah.05@gmail.com> writes:
> I analyzing some netwokr log files. There are around 200-300 files and
> each file has more than 2 million entries in it.
>
> Currently my script is reading each file line by line. So it will take
> lot of time to process all the files.
It depends on what kind of processing you're doing.
If you don't need to process lines in order you might get a speedup by
starting a couple of processes each processing their own files. Again
depending on the kind of processing the optimal number of processes
may vary from the number om cpu's to a copule times the number of
cpu's.
If part of you processing consists of doing a DNS lookup you might be
able to get a speedup by reading a few lines a time a use asyncronous
dns requests (Net::DNS::Async seems to do it) instead of block on each
and every request.
Other optimizations might be possible, but almost everything depends
on the kind of processing you have to do and if you have to process
lines in some predetermined order.
//Makholm
------------------------------
Date: Thu, 11 Dec 2008 21:45:57 +0000
From: RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Subject: Re: Processing Multiple Large Files
Message-Id: <ghs1mo$35f$1@news.motzarella.org>
friend.05@gmail.com wrote:
> Hi,
>
> I analyzing some netwokr log files. There are around 200-300 files and
> each file has more than 2 million entries in it.
>
> Currently my script is reading each file line by line. So it will take
> lot of time to process all the files.
>
> Is there any efficient way to do it?
>
> May be Multiprocessing, Multitasking ?
>
If the 200-300 files are on the same disk, are not especially fragmented
and your program is already IO-bound, parallel processing might
conceivably slow things down by increasing the number of head-seeks needed.
Just a thought.
--
RGB
------------------------------
Date: Thu, 11 Dec 2008 23:57:13 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Processing Multiple Large Files
Message-Id: <Xns9B71C0CDC9E12asu1cornelledu@127.0.0.1>
"friend.05@gmail.com" <hirenshah.05@gmail.com> wrote in news:5f1e2237-
b3f6-409c-aa95-b7ba57955265@q26g2000prq.googlegroups.com:
> I analyzing some netwokr log files. There are around 200-300 files and
> each file has more than 2 million entries in it.
>
> Currently my script is reading each file line by line. So it will take
> lot of time to process all the files.
>
> Is there any efficient way to do it?
>
> May be Multiprocessing, Multitasking ?
Here is one way to do it using Parallel::Forkmanager.
If your system is somewhat typical, you'll probably run into an IO
bottleneck before you run into a CPU bottleneck.
For example:
C:\DOCUME~1\asu1\LOCALS~1\Temp\large> cat create.pl
#!/usr/bin/perl
use strict;
use warnings;
my $line = join("\t", qw( 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 )) .
"\n";
my $fn_tmpl = 'data_%2.2d.txt';
my $fn = sprintf $fn_tmpl, 0;
open my $out, '>', $fn
or die "Cannot open '$fn': $!";
for (1 .. 100_000) {
print $out $line
or die "Cannot write to '$fn': $!";
}
close $out
or die "Cannot close: '$fn': $!";
for (1 .. 19) {
system copy => $fn, sprintf($fn_tmpl, $_);
}
C:\DOCUME~1\asu1\LOCALS~1\Temp\large> timethis create
...
TimeThis : Command Line : create
TimeThis : Start Time : Thu Dec 11 18:14:12 2008
TimeThis : End Time : Thu Dec 11 18:14:16 2008
TimeThis : Elapsed Time : 00:00:03.468
Now, you have 20 input files with 100_000 lines each:
C:\DOCUME~1\asu1\LOCALS~1\Temp\large> dir
...
2008/12/11 06:14 PM 4,100,000 data_00.txt
2008/12/11 06:14 PM 4,100,000 data_01.txt
2008/12/11 06:14 PM 4,100,000 data_02.txt
2008/12/11 06:14 PM 4,100,000 data_03.txt
2008/12/11 06:14 PM 4,100,000 data_04.txt
2008/12/11 06:14 PM 4,100,000 data_05.txt
2008/12/11 06:14 PM 4,100,000 data_06.txt
2008/12/11 06:14 PM 4,100,000 data_07.txt
2008/12/11 06:14 PM 4,100,000 data_08.txt
2008/12/11 06:14 PM 4,100,000 data_09.txt
2008/12/11 06:14 PM 4,100,000 data_10.txt
2008/12/11 06:14 PM 4,100,000 data_11.txt
2008/12/11 06:14 PM 4,100,000 data_12.txt
2008/12/11 06:14 PM 4,100,000 data_13.txt
2008/12/11 06:14 PM 4,100,000 data_14.txt
2008/12/11 06:14 PM 4,100,000 data_15.txt
2008/12/11 06:14 PM 4,100,000 data_16.txt
2008/12/11 06:14 PM 4,100,000 data_17.txt
2008/12/11 06:14 PM 4,100,000 data_18.txt
2008/12/11 06:14 PM 4,100,000 data_19.txt
Here is a simple program to process the data:
C:\DOCUME~1\asu1\LOCALS~1\Temp\large> cat process.pl
#!/usr/bin/perl
use strict;
use warnings;
use Parallel::ForkManager;
my ($instances) = @ARGV;
my $fn_tmpl = 'data_%2.2d.txt';
my $pm = Parallel::ForkManager->new($instances);
for my $i (0 .. 19 ) {
$pm->start and next;
my $input = sprintf $fn_tmpl, $i;
eval {
open my $in, '<', $input
or die "Cannot open '$input': $!";
while ( my $line = <$in> ) {
my @data = split /\t/, $line;
# replace with your own processing code
# don't try to keep all your data in memory
}
close $in
or die "Cannot close '$input': $!";
};
warn $@ if $@;
$pm->finish;
}
$pm->wait_all_children;
__END__
First, try without forking to establish a baseline:
C:\DOCUME~1\asu1\LOCALS~1\Temp\large> timethis process 0
TimeThis : Command Line : process 0
TimeThis : Start Time : Thu Dec 11 18:31:50 2008
TimeThis : End Time : Thu Dec 11 18:32:41 2008
TimeThis : Elapsed Time : 00:00:51.156
Let's try a few more:
TimeThis : Command Line : process 2
TimeThis : Start Time : Thu Dec 11 18:35:15 2008
TimeThis : End Time : Thu Dec 11 18:35:58 2008
TimeThis : Elapsed Time : 00:00:43.578
TimeThis : Command Line : process 4
TimeThis : Start Time : Thu Dec 11 18:36:17 2008
TimeThis : End Time : Thu Dec 11 18:36:59 2008
TimeThis : Elapsed Time : 00:00:41.921
TimeThis : Command Line : process 8
TimeThis : Start Time : Thu Dec 11 18:37:18 2008
TimeThis : End Time : Thu Dec 11 18:38:00 2008
TimeThis : Elapsed Time : 00:00:41.328
TimeThis : Command Line : process 16
TimeThis : Start Time : Thu Dec 11 18:38:18 2008
TimeThis : End Time : Thu Dec 11 18:38:58 2008
TimeThis : Elapsed Time : 00:00:40.734
TimeThis : Command Line : process 20
TimeThis : Start Time : Thu Dec 11 18:39:17 2008
TimeThis : End Time : Thu Dec 11 18:39:58 2008
TimeThis : Elapsed Time : 00:00:40.578
Not very impressive. Between no forking vs max 20 instances, time
required to process was reduced by 20% with most of the gains coming
from running 2. That probably has more to do with the implementation of
fork on Windows than anything else.
In fact, I should probably have used threads on Windows. Anyway, I'll
boot into Linux and see if the returns there are greater.
Try this simple experiment on your system. See how many instances gives
you the best bang-per-buck.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
------------------------------
Date: Thu, 11 Dec 2008 21:11:20 -0500
From: "Thrill5" <nospam@somewhere.com>
Subject: Re: querying Active Directory via LDAP in perl
Message-Id: <ghsh8c$vd$1@nntp.motzarella.org>
<joseph85750@yahoo.com> wrote in message
news:03a34234-c330-464e-9a0c-6bd65c28b96b@k36g2000pri.googlegroups.com...
> I've been poking at this on and off over the past few months, never
> having much success. I was never sure what sort of crazy query string
> the AD server wanted. But then it occurred to me that my Linux
> Evolution email client does this without any problems-- only using the
> IP address of the Active Directory LDAP server. I can query/search,
> and it immediately returns all matches.
>
> How can it do this without the big ugly
> "cn=users,dc=foo,dc=blah,o=acme......" string ?
>
> Since this is obviously possible and simple (except for me), how could
> I do this same simple query in perl-- only armed with the IP address
> of my AD/LDAP server?
>
> Curiously,
> JS
Google "LDAP query syntax", and you will find a whole bunch of information
about querying AD via LDAP.
------------------------------
Date: Thu, 11 Dec 2008 13:32:39 -0800 (PST)
From: jps <jpsweden@gmail.com>
Subject: Re: The single biggest STUPIDITY in Perl ...
Message-Id: <dc5829e7-a726-4dfd-b9f9-0018c3a7439f@w39g2000prb.googlegroups.com>
On Dec 11, 2:25=A0am, "A. Sinan Unur" <1...@llenroc.ude.invalid> wrote:
> ...what is so unreadable about:
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my @x =3D ( [1,2], [3,4] );
>
> print $x[1][0], "\n";
Heeey! Youre CHEATING!
And the "use strict" pragma is BROKEN!!! :D
Mannerly Perl syntax is:
A) $x[0]->[1]
or
B) ${$x[0]}[1]
But thats not where the trouble is -- it comes when you start calling
subroutines with arrays and hashes in the parameter-list... which you
CANT! :)
------------------------------
Date: Thu, 11 Dec 2008 13:48:45 -0800 (PST)
From: jps <jpsweden@gmail.com>
Subject: Re: The single biggest STUPIDITY in Perl ...
Message-Id: <d728201a-1a9e-4e29-aa4d-b2c7c9529ff3@i20g2000prf.googlegroups.com>
On Dec 11, 2:25=A0am, "A. Sinan Unur" <1...@llenroc.ude.invalid> wrote:
> > If -for example- you could just write
> > =A0 =A0my @list =3D ((1,2),(3,4));
> > to get a 2x2 matrix (rather than 4-element list) I think the code
> > could be soooo much more elegant, and easier to write in a much more
> > readable fashion.
>
> First, @list is an array.
Wrong! It's BOTH. Perl cant tell the difference :)
------------------------------
Date: Thu, 11 Dec 2008 17:06:16 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: The single biggest STUPIDITY in Perl ...
Message-Id: <x78wqm8izr.fsf@stemsystems.com>
>>>>> "j" == jps <jpsweden@gmail.com> writes:
j> On Dec 11, 2:25 am, "A. Sinan Unur" <1...@llenroc.ude.invalid> wrote:
>> > If -for example- you could just write
>> > my @list = ((1,2),(3,4));
>> > to get a 2x2 matrix (rather than 4-element list) I think the code
>> > could be soooo much more elegant, and easier to write in a much more
>> > readable fashion.
>>
>> First, @list is an array.
j> Wrong! It's BOTH. Perl cant tell the difference :)
i know you have a smiley but perl can tell the difference between lists
and arrays as they are very different animals which have only a couple
of actual similarities.
about the only thing you can do with both lists and arrays is accessing
elements using numeric indices or fixed ordering. this includes index
accesses, slices, list context assignments and arg lists, etc.
but the number of differences are more common:
arrays lists
------ -----
can change size fixed size
allocated from the heap allocated on the stack
freed later by freed after expression is done
garbage collector
lives between statements lives in a single part of an expression
can take references no referencing
can be passed around code can only be used one time
in its expression
can be given a name no name is possible
can make nested trees lists are one dimensional
so you can see they are very different with some listy operations in
common. that is why perl hackers get annoyed when people confuse lists
and arrays.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Thu, 11 Dec 2008 16:52:18 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: The single biggest STUPIDITY in Perl ...
Message-Id: <slrngk36d2.klj.tadmc@tadmc30.sbcglobal.net>
jps <jpsweden@gmail.com> wrote:
> On Dec 11, 2:25 am, "A. Sinan Unur" <1...@llenroc.ude.invalid> wrote:
>> First, @list is an array.
>
> Wrong! It's BOTH.
No it isn't.
@list is an array.
@list _contains_ a list.
Just as with
$num = 3;
$num is a (scalar) variable.
$num contains a number.
> Perl cant tell the difference :)
Yes it can.
An array has a changeable length. A list does not. An array is something
you can push or pop, while a list is a set of values. Some people make
the distinction that a list is a value while an array is a variable.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Thu, 11 Dec 2008 13:34:52 -0800 (PST)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: Trouble with Net::Ping
Message-Id: <574304b2-edf0-4072-b6ef-d4dad59862f4@y1g2000pra.googlegroups.com>
On Dec 10, 5:46=A0pm, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> On 2008-12-09 06:14, Ted Byers <r.ted.by...@gmail.com> wrote:
>
> > On Dec 8, 7:29=A0pm, Big and Blue <N...@dsl.pipex.com> wrote:
> >> Ted Byers wrote:
> >> > Here is a little script assembled fromt he documentation for
> >> > Net::Ping.
>
> >> That same documentation will show that Net::Ping, by default, tries to
> >> open a TCP socket to the destination.
>
> > Yes, I noticed that. =A0I also noticed that the documentation said it
> > was the slowest because it is a higher level protocol than the others,
> > doing checks the others don't. =A0My recollection is a bit fuzzy, but
> > IIRC TCP lives on top of UDP (and thus it makes sense that UDP would
> > be faster)
>
> No. UDP and TCP are at the same level - both are layered on IP. Same for
> ICMP although it is more tightly coupled to IP.
>
OK.
> > and http lives on top of TCP. =A0Since I would expect a web
> > client like a browser based on LWP would be using http exchanges,
>
> Maybe I'm mixing up threads, but didn't you have problems with FTP?
> That's a different protocol then HTTP. Both use TCP, but you can't debug
> either of them properly by trying to connect to TCP port 7 (which is
> what Net::Ping does).
>
>
Actually, I am having trouble with both. One script uses Net::FTP to
transfer archives from one of our servers to another across the
country, and the other uses LWP to retrieve a data feed from one of
our suppliers. Both work flawlessly when the amount of data is small
(up to a few hundred k) and both time out when the amount of data is
large (a few MB). Might it be that the client merely thinks the
connection has timed out but that the requested data is still being
transferred? I know that the script that pushes our large archives to
our other server does complete the transfer of the larger files (we
can open them and see they're intact), but then dies believing the
connection is broken and so never makes an attempt to send the next
file in thelist. We managed to work around this by opening the
connection to the ftp server just before trying to transfer a file and
closing it immediately after sending the file (something my colleague
- our system administrator - set up). It seems stupid to have to
close and reopen the ftp connection between large files, especially
when that is unnecessary with smal ones. Is there a better way?
WRT LWP, when the transfer fails, we work around it by recursively
partitioning the period for which we're requesting data into smaller
and smaller sub-intervvals until we get all the data. This is only
necessary when there is several MB worth of data to be retrieved.
Again, is there a better way?
>
>
>
> > it makes sense that if there is trouble with a given http exchange,
> > one should check the foundation it is built on, from the top down.
>
> >> > =A0 =A0 =A0 =A0You may choose one of six different protocols to use =
for the ping. The
> >> > =A0 =A0 =A0 =A0"tcp" protocol is the default. Note that a live remot=
e host may still
> >> > =A0 =A0 =A0 =A0fail to be pingable by one or more of these protocols=
. For example,
> >> > =A0 =A0 =A0 =A0www.microsoft.comisgenerally alive but not "icmp" pin=
gable.
>
> >> The ping command uses ICMP.
>
> >> These are different Internet Protocols.
>
> > Yes, I know they're different protocols. =A0But, as you note and I had
> > already observed, the documentation says tcp is the default protocol,
> > and thatwww.microsoft.comis generally alive but not icmp pingable.
> > That is why I tried the default TCP first.
>
> > But there is a problem, here, with what you've written. =A0You say the
> > ping command uses ICMP, but you saywww.microsoft.comis not ICMP
> > pingable. =A0I used the ping command provided by MS with WXP. =A0Why wo=
uld
> > that use ICMP ifwww.microsoft.comis not ICMP pingable.
>
> MS ping uses ICMP because that's its job. "ping" is the command which
> checks if a host replies to ICMP echo requests. For some reason
> Microsoft doesn't want its web servers to reply to ICMP echo requests.
> Maybe they think you should use a browser to look at a webserver, not
> ping ;-).
>
OK. But that makes them unfriendly when one needs to check
connectivity.
> >> > Is there something in configuring Net::Ping that can make it useful
> >> > for automating checking connectivity (in the context of handling
> >> > situations where, say, and LWP agent fails to retieve data as expect=
ed
> >> > - did we get no data because there was no data or because the
> >> > connection was lost or some other reason)?
>
> >> LWP itself will tell you that. =A0As noted, the "ping" command itself =
uses
> >> ICMP - a protocol which would be of little use for data transfer, and
> >> certainly not used by LWP.
>
> > I don't understand why you're on about ICMP when the documentation
> > says it is only one of three protocols, and the default protocol is
> > TCP.
>
> Probably to explain why it is possible that the ping command shows a
> host as alive (that is it replies to ICMP echo requests) but Net::Ping
> doesn't (because a connection request to TCP port 7 (echo) times out),
> or vice versa. They are just completely different protocols and a
> firewall may block one but not the other. (Incidentally, if a firewall
> does block requests with a port-unreachable message, Net::Ping thinks
> the host is alive, although it may be down).
>
OK. That makes sense.
> > In any event, LWP gives only a mention that a given transfer timed out
> > (and it happens only when trying to transfer a multimegabyte file),
> > but not why. =A0I DID use the LWP::DebugFile package for this, but the
> > data doesn't seem very detailed.
>
> > I was, in fact, advised in this forum to check connectivity between
> > the machines in the transaction using ping and traceroute.
>
> Yes. The commands "ping" and "traceroute". They already exist and are
> almost certainly installed on your linux server. No need to write a
> replacement in Perl.
>
OK. But the server running my script is Windows. There traceroute is
tracert (unless Windows Server uses a different name than the other
versions of Windows). And for the purpose of automating checking of
connectivity one would need a little extra code to invoke these OS
commands and parse the output to check for success or failure
(something I'd assumed was what Net::Ping and Net::Traceroute were
made for, but it appears that was wrong).
Thanks
Ted
------------------------------
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 V11 Issue 2050
***************************************