[18330] in Perl-Users-Digest
Perl-Users Digest, Issue: 498 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 15 21:05:46 2001
Date: Thu, 15 Mar 2001 18:05:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <984708314-v10-i498@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 15 Mar 2001 Volume: 10 Number: 498
Today's topics:
Re: @a->[8] vs. $a[8] (Randal L. Schwartz)
Re: @a->[8] vs. $a[8] <mischief@velma.motion.net>
Re: @a->[8] vs. $a[8] (Randal L. Schwartz)
Re: binary files <mischief@velma.motion.net>
Re: binary files (Abigail)
Re: binary files <mischief@velma.motion.net>
Re: binary files <uri@sysarch.com>
dbmfiles access time <jhall@ifxonline.com>
Re: Does Perl have an un-getc <ttracy@houston.rr.com>
Re: FAQ 7.12: What's a closure? (Abigail)
Re: FAQ 7.12: What's a closure? (Abigail)
Re: FAQ 7.12: What's a closure? <uri@sysarch.com>
Re: FAQ 7.12: What's a closure? <uri@sysarch.com>
Re: Getopt::Std swallows argument even if ":" not speci (Jay Tilton)
Re: Grokking map and grep <persicom@acedsl.com>
Re: HTTP Client Question <bart.lateur@skynet.be>
Re: HTTP Client Question <bactitech@hortonsbay.com>
Re: Keystroke shortcuts (Monte)
Net::Telnet problem - 1 attachments (Anson Ng)
Re: pattern matching (Jay Tilton)
Re: Perl 4 (Martien Verbruggen)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Mar 2001 15:34:28 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: @a->[8] vs. $a[8]
Message-Id: <m1elvy7gjf.fsf@halfdome.holdit.com>
>>>>> "John" == John W Krahn <krahnj@acm.org> writes:
John> perldoc perlfaq4
John> What is the difference between $array[1] and @array[1]?
John> The former is a scalar value, the latter an array slice,
John> which makes it a list with one (scalar) value. You should
John> use $ when you want a scalar value (most of the time) and
John> @ when you want a list with one scalar value in it (very,
John> very rarely; nearly never, in fact).
Not related here.
@a->[4]
should technically be, according to the spec:
(scalar @a)->[4]
since -> provides scalar context to the left side. So this would
be the number of elements of @a, interpreted as an arrayref, dereferenced,
and then element 4 selected.
So if @a had 27 elements, this would be $27[4], the fifth element of @27
(a legal array name :).
Now, the problem is, this thing is *treated* as if you had said
(\@a)->[4]
because @a acts as an lvalue until needed to be an rvalue. That's the
deep mojo. So we have an implicit referencing, a definite faux pas.
It *does* *not* act as if it was @a[4], because it provides
scalar context, as demonstrated by this:
print map "<$_>", @a->[4] = gmtime;
which just printed "<Thu Mar 15 23:32:55 2001>", showing that
we've got a scalar assignment going on. Contrast that with:
print map "<$_>", @a[4] = gmtime;
Which just printed "<40>", the seconds entry, so gmtime is in a list
context. So @a->[4] is $a[4], not @a[4].
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Fri, 16 Mar 2001 01:11:04 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: @a->[8] vs. $a[8]
Message-Id: <tb2q18gg3ttrcd@corp.supernews.com>
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "John" == John W Krahn <krahnj@acm.org> writes:
> John> perldoc perlfaq4
> John> What is the difference between $array[1] and @array[1]?
> John> The former is a scalar value, the latter an array slice,
> John> which makes it a list with one (scalar) value. You should
> John> use $ when you want a scalar value (most of the time) and
> John> @ when you want a list with one scalar value in it (very,
> John> very rarely; nearly never, in fact).
> Not related here.
> @a->[4]
> should technically be, according to the spec:
> (scalar @a)->[4]
> since -> provides scalar context to the left side. So this would
> be the number of elements of @a, interpreted as an arrayref, dereferenced,
> and then element 4 selected.
> So if @a had 27 elements, this would be $27[4], the fifth element of @27
> (a legal array name :).
Wouldn't it be more like ${\@a}[4]? At least I understand where those
values come from better than I understand your example.
Chris
--
Christopher E. Stith
Parking for people we like only. All other vehicles will be vandalized.
------------------------------
Date: 15 Mar 2001 18:04:51 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: @a->[8] vs. $a[8]
Message-Id: <m1k85q5v0c.fsf@halfdome.holdit.com>
>>>>> "Chris" == Chris Stith <mischief@velma.motion.net> writes:
Chris> Wouldn't it be more like ${\@a}[4]? At least I understand where those
Chris> values come from better than I understand your example.
Uh, yeah. Precisely:
${ FOO } [ 4 ]
is the same as
( FOO ) -> [ 4 ]
And for certain FOO's, you can leave off the parens and/or curly braces
(though not the same FOO's :).
print ["Just another Perl hacker,"]->[0],
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Fri, 16 Mar 2001 00:07:39 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: binary files
Message-Id: <tb2mab60pqj6d6@corp.supernews.com>
Todd Smith <todd@designsouth.net> wrote:
> I just want to be able to translate a file into a file containing 1's and
> 0's (Binary). Then I'll take that file in perl and play with it later.
> uuencode seems to do a good job but how do i get only the 1's and 0's of
> real binary data?
Short answer: you don't.
Not so short answer: you don't have to, because the system gives
the data a byte at a time or larger, and it's still binary.
Medium answer: The ones and zeros are a figment of someone's
imagination. They are actually just open/closed states of
an electric circuit (a very small one, on the chip). The
data stored in a file is said to be `binary' if it doesn't
all represent plain, readable text. The files is mp3, jpeg,
au, png, and other files of their ilk _are_ binary files.
There are Perl modules to deal with many of them. Check
CPAN.
There are NSL and L answers, but I'll save that much typing
for a request. There may even be an EL answer, but I'd have
to see how my fingers feel first.
[snipped whole post of Gwyn's that Todd top-posted above.
Please don't top-post. Post in the context of the post
to which you are replying, and snip any data not relevant
to your own post. It makes it easier to read later.]
Chris
--
Christopher E. Stith
It's not the U in UBE that pisses people off. It's the B.
-- Martien Verbruggen in clp.misc
------------------------------
Date: 16 Mar 2001 00:10:56 GMT
From: abigail@foad.org (Abigail)
Subject: Re: binary files
Message-Id: <slrn9b2mgg.p0e.abigail@tsathoggua.rlyeh.net>
Michael Carman (mjcarman@home.com) wrote on MMDCCLIII September MCMXCIII
in <URL:news:3AB1467A.6F9F8685@home.com>:
{} Todd Smith wrote:
{} >
{} > Is there a way to convert any file (picture, mp3, text, or anything)
{} > to a binary file that I can read (with a bunch of 1's and 0's) and
{} > convert it back to the original file from the binary? A Perl module
{} > maybe?
{}
{} All data contained within a computer is binary. (Well, until the quantum
{} PCs start coming out, at least ;) You should of course always use
{} binmode() when processing a file that contains anything other than pure
{} text, but that doesn't "convert" the file, it just affects the I/O
{} processing.
Analoge computers do exist. Perhaps less now than 20 years ago, but
not every computer is binary.
And while extremely rare, 10 and 3 state based computers exist too.
Abigail
--
$" = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_) {print "$_ $_{$_} "}};
%_ = (Just => another => Perl => Hacker); &{%_};
------------------------------
Date: Fri, 16 Mar 2001 01:01:10 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: binary files
Message-Id: <tb2pemp6o6ppa7@corp.supernews.com>
Abigail <abigail@foad.org> wrote:
> Michael Carman (mjcarman@home.com) wrote on MMDCCLIII September MCMXCIII
> in <URL:news:3AB1467A.6F9F8685@home.com>:
> {} Todd Smith wrote:
> {} >
> {} > Is there a way to convert any file (picture, mp3, text, or anything)
> {} > to a binary file that I can read (with a bunch of 1's and 0's) and
> {} > convert it back to the original file from the binary? A Perl module
> {} > maybe?
> {}
> {} All data contained within a computer is binary. (Well, until the quantum
> {} PCs start coming out, at least ;) You should of course always use
> {} binmode() when processing a file that contains anything other than pure
> {} text, but that doesn't "convert" the file, it just affects the I/O
> {} processing.
> Analoge computers do exist. Perhaps less now than 20 years ago, but
> not every computer is binary.
True, but according to the definition many people use for `computer',
these are right out. They theoretically can do much of the same
processing, but there isn't one that is implemented that can compete
with any modern computer.
> And while extremely rare, 10 and 3 state based computers exist too.
True enough. Now, find me one that's base 3 or base 10 where I can
run perl, and I'll buy you lunch for a week.
Chris
--
Christopher E. Stith
The purpose of a language is not to help you learn the
language, but to help you learn other things by using the
language. --Larry Wall, The Culture of Perl, August 1997
------------------------------
Date: Fri, 16 Mar 2001 01:09:38 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: binary files
Message-Id: <x78zm68qp8.fsf@home.sysarch.com>
>>>>> "CS" == Chris Stith <mischief@velma.motion.net> writes:
>> And while extremely rare, 10 and 3 state based computers exist too.
CS> True enough. Now, find me one that's base 3 or base 10 where I can
CS> run perl, and I'll buy you lunch for a week.
IIRC the russians did some base 3 systems. i think they did some
research and found that was more space effcient than binary. they were
true 3 state logic systems, using 3 voltage levels per tri-digit
(trit?). i doubt perl has ever run on any of those.
many mainframes and vaxes support decimal math in hardware but that is
BCD. i think some early/ancient computers were all BCD but i never heard
of one that was true 10 state logic. that would be so tricky to build.
perl does run on machines which support BCD but no perl ops or data can
directly get at those instructions. the best you could do is pack/unpack
and use inline with assembler. then we wouldn't have to hear about all
the rounding issues from float newbies. :)
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Thu, 15 Mar 2001 23:44:25 GMT
From: "John Hall" <jhall@ifxonline.com>
Subject: dbmfiles access time
Message-Id: <ttcs6.32849$o7.1326008@news1.rdc1.sdca.home.com>
Because I enjoy simplicity, and admittedly, because I'm new at this; I would
like to use the "builtin" dbm functions that came with both my activestate
komodo 1.0 and the generic 5.00503 install on a linuxppc/apache box I host
toys on.
I want to know how much I can reasonably stretch out of those simple db
files you create via a:
dbmopen(%hash, "filename", perm);
In terms of amount of records stored and size of values for keys.
Say i'm running a ~200mhz PPC 603e with 64 megs of ram, and I want to host a
script [assuming it somewhat intelligently written] that accesses a db
created with this method with ~600 records in it with value sizes averaging
1k? Now say my box is getting 10k hits a day, most of those hits are calls
to a simple 'displayer' script that grabs a value from the dbm file and
displays it via an SSI.
Is this preposterous?
------------------------------
Date: Thu, 15 Mar 2001 23:47:59 GMT
From: "Tim Tracy" <ttracy@houston.rr.com>
Subject: Re: Does Perl have an un-getc
Message-Id: <Pwcs6.59080$YC1.14347863@typhoon.austin.rr.com>
Greg,
Your suggestion worked great. I used the seek function to achieve the
desired "un-getc" functionality and it worked great.
Thanks for the assist!
Tim
"Greg Bacon" <gbacon@HiWAAY.net> wrote in message
news:tatadq86q9u218@corp.supernews.com...
> In article <tjvr6.57615$Fz.12400366@typhoon.austin.rr.com>,
> Tim Tracy <ttracy@houston.rr.com> wrote:
>
> : Thanks for your prompt reply. It will experiment with your suggestions.
>
> Actually my program has a bug. I thought the getc() in the while
> condition had an implicit defined() check, but it doesn't. The code
> should be
>
> #! /usr/local/bin/perl -w
>
> use strict;
>
> use Fcntl qw/ SEEK_CUR /;
>
> open IN, "input" or die "$0: open input: $!\n";
>
> my $back_that_ass_up = 1;
>
> # add check for defined()-ness; was
> # while (my $c = getc IN) {
> while ( defined(my $c = getc IN) ) {
> printf "GOT: '$c' (0x%02x)\n", unpack "C" => $c;
>
> if ($c eq '3' && $back_that_ass_up) {
> seek IN, -2, SEEK_CUR or die "$0: seek: $!\n";
> $back_that_ass_up = 0;
> }
> }
>
> To tickle the bug, try an input file with '120123abc' on a line.
>
> Greg
> --
> If there be any among us who wish to dissolve the Union or to change its
> republican form, let them stand undisturbed, as monuments of the safety
> with which error of opinion may be tolerated where reason is left free to
> combat it. -- Thomas Jefferson
------------------------------
Date: 16 Mar 2001 00:01:57 GMT
From: abigail@foad.org (Abigail)
Subject: Re: FAQ 7.12: What's a closure?
Message-Id: <slrn9b2lvl.p0e.abigail@tsathoggua.rlyeh.net>
Uri Guttman (uri@sysarch.com) wrote on MMDCCLIII September MCMXCIII in
<URL:news:x7lmq68x43.fsf@home.sysarch.com>:
`` >>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:
``
`` BL> Abigail wrote:
`` >> OTOH, there are a lot of reason you might want to use closure in
`` >> Perl. It's implementation of OO, for instance.
``
`` BL> Now there's an interesting thought. So, care to expand on what this
`` BL> would look like?
``
`` like i said, read about OO closures in OOP by conway.
"Its" refers to "Perl".
Abigail
------------------------------
Date: 16 Mar 2001 00:02:45 GMT
From: abigail@foad.org (Abigail)
Subject: Re: FAQ 7.12: What's a closure?
Message-Id: <slrn9b2m14.p0e.abigail@tsathoggua.rlyeh.net>
Uri Guttman (uri@sysarch.com) wrote on MMDCCLIII September MCMXCIII in
<URL:news:x7hf0u8wo0.fsf@home.sysarch.com>:
^^ >>>>> "A" == Abigail <abigail@foad.org> writes:
^^
^^ A> Just for kicks, here's a way to do OO using closures. That is, MI, SUPER::
^^ A> and AUTOLOAD, without using bless, or the need to pack your instances
^^ A> variables in a structure.
^^
^^ A> package OO::Closures;
^^
^^ also see Class::Classless on CPAN for a different approach. i believe
^^ it also uses closures and perl refs but none of perl's builtin OO stuff.
I believe Class::Classless was inspired by OO::Closures.
Abigail
--
# Perl 5.6.0 broke this.
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi
------------------------------
Date: Fri, 16 Mar 2001 00:57:04 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: FAQ 7.12: What's a closure?
Message-Id: <x7elvy8ra9.fsf@home.sysarch.com>
>>>>> "A" == Abigail <abigail@foad.org> writes:
A> Uri Guttman (uri@sysarch.com) wrote on MMDCCLIII September MCMXCIII in
A> <URL:news:x7hf0u8wo0.fsf@home.sysarch.com>:
A> ^^ also see Class::Classless on CPAN for a different approach. i believe
A> ^^ it also uses closures and perl refs but none of perl's builtin OO stuff.
A> I believe Class::Classless was inspired by OO::Closures.
dunno. i first heard about it at damian advanced OO lecture at yapc last
year. this is the first time i have heard about OO::Closures.
other than the very different api and some feature differences (SUPER,
etc.) what other diffs are there? speed?
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Fri, 16 Mar 2001 01:16:26 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: FAQ 7.12: What's a closure?
Message-Id: <x766ha8qe0.fsf@home.sysarch.com>
>>>>> "A" == Abigail <abigail@foad.org> writes:
A> Uri Guttman (uri@sysarch.com) wrote on MMDCCLIII September MCMXCIII in
A> <URL:news:x7hf0u8wo0.fsf@home.sysarch.com>:
A> ^^ also see Class::Classless on CPAN for a different approach. i believe
A> ^^ it also uses closures and perl refs but none of perl's builtin OO stuff.
A> I believe Class::Classless was inspired by OO::Closures.
i just checked with the author of Class::Classless and he said he wasn't
influenced by OO::Closures and it doesn't use closures at all.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Thu, 15 Mar 2001 23:13:43 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Getopt::Std swallows argument even if ":" not specified?
Message-Id: <3ab140d4.54099789@news.erols.com>
On Thu, 15 Mar 2001 16:03:34 -0500, "Antoine Beaupre (LMC)"
<lmcabea@lmc.ericsson.se> wrote:
>I expected the following code:
> my (%opts) = ();
> message "ARGV is @ARGV now";
> getopt('qvf:', \%opts);
> message "ARGV is @ARGV now";
>To output something like:
>
>====> ARGV is -v -q -v P1 OU/ADMINDATA now
>====> ARGV is P1 OU/ADMINDATA now
>
>but instead I had:
>
>====> ARGV is -v -q -v P1 OU/ADMINDATA now
>====> ARGV is OU/ADMINDATA now
>Don't give me that "it's-not-a-bug-it's-a-feature" crap. :)
I wouldn't dream of it, since it's neither.
'getopt' matches switches with arguments. That's all it does.
In your case above, the ':' is making it look for a '-:' switch. The
first -v and -q have no arguments, so they're discarded. The second
-v gets associated with the argument 'P1'. %opts = ( v=>'P1' )
'getopts' does that and sets Boolean flags. A ':' here makes it match
a switch with an argument. If you instead say...
getopts('qvf:', \%opts);
...then %opts = ( q=>1, v=>1 ), and @ARGV keeps the P1. See if this
is not what you intended.
perldoc Getopt::Std
------------------------------
Date: Thu, 15 Mar 2001 20:55:19 -0500
From: "Matthew O. Persico" <persicom@acedsl.com>
Subject: Re: Grokking map and grep
Message-Id: <3AB17287.5134ECBC@acedsl.com>
Philip Lees wrote:
>
> On Wed, 14 Mar 2001 00:01:43 -0500, "Matthew O. Persico"
> <persicom@acedsl.com> wrote:
>
> >Hmm. If you are going to sort on field 0 anyway, and then rejoin on the
> >delimiter, why bother? Save some cycles and try this:
> >
> >print OUT map { ++$count; $_ } sort { $a <=> $b } grep { /^\d+,/ } <IN>;
>
> Well, this works in that it produces the right output, but it
> generates a metric buttload of warning messages about the sort
> argument not being numeric.
Sorry. I keep prototyping these things using perl -de 42. I should at
least use perl -wde 42. Try this:
{
local $^W = 0;
print OUT map { ++$count; $_ } sort { $a <=> $b } grep { /^\d+,/ }
<IN>;
}
--
Matthew O. Persico
http://www.acecape.com/dsl
AceDSL:The best ADSL in Verizon area
------------------------------
Date: Thu, 15 Mar 2001 23:59:26 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: HTTP Client Question
Message-Id: <iql2bt0uuc1ocjo4c7eg59k4pgka32or65@4ax.com>
Al Spohn wrote:
>So my question may
>not have been Perl specific, but the answer could/might well have been.
And it gets worse. The whole thread (30 messages I can count)
degenerates, again, into one that isn't even technology related.
--
Bart.
------------------------------
Date: Thu, 15 Mar 2001 19:44:15 -0500
From: Dilworth <bactitech@hortonsbay.com>
Subject: Re: HTTP Client Question
Message-Id: <3ab161f3$0$18899$1dc6e903@news.corecomm.net>
"Scott R. Godin" wrote:
>
> what's a "taliban" ?
The Taliban is the right wing government of Afganistan, which just blew
up ancient Buddhas in their attempt to get people to follow the rules.
Hmmmmm...........
Judy Dilworth
(Bob's spouse - couldn't resist answering this question.....!)
------------------------------
Date: Fri, 16 Mar 2001 01:11:11 GMT
From: montep@about.com (Monte)
Subject: Re: Keystroke shortcuts
Message-Id: <3ab166ad.41662527@news.hal-pc.org>
On Thu, 15 Mar 2001 16:14:02 GMT, lkenny@fisheries.org (LK) wrote:
>Is there a way to get perl to use keystroke shortcuts when reading a
>document? If so, how, or where can I look to find out how. (I
>already tried the perlfaq but didn't find anything)
>
>LK
If I understand you(highly problematic). You are asking if you can
code in such things as SHFT Insert CTRL ENTER HOME or other common
keyboard shortcuts,. The answer is NO. Why would you?
For perl or any other program to do its work it needs to look at
everything in the file, right? If you had it jumping to the end of
words or lines then it would probably miss what it was supposed to
see.
Now if you are asking could you perl these as 'alias' into a bashrc
file yes. But again, why would you want to?
Are you really just trying to speed a process?
g'Luk
Monte
f your gonna spam.....
admin@loopback, $LOGIN@localhost, $LOGNAME@localhost,
$USER@localhost, $USER@$HOST, -h1024@localhost, root@mailloop.com
root@localhost, postmaster@localhost, admin@localhost, abuse@localhost
Chairman Reed Hundt: rhundt@fcc.gov
Commissioner James Quello: jquello@fcc.gov
Commissioner Susan Ness: sness@fcc.gov
Commissioner Rachelle Chong: rchong@fcc.gov
US Postal Service: customer@email.usps.gov
Fraud Watch: fraudinfo@psinet.com
Pyramid Schemes: pyramid@ftc.gov
Federal Trade Commission: consumerline@ftc.gov
net-abuse@nocs.insp.irs.gov
------------------------------
Date: 16 Mar 2001 01:07:25 GMT
From: anson@mail.com (Anson Ng)
Subject: Net::Telnet problem - 1 attachments
Message-Id: <Xns9065CCD6D1A67ansonmailcom@9.21.4.171>
The following is my source code.
I tried to use Net::Telnet on my NT box (ActivePerl 5.6.0 build 623) to
connect to another host after FTPing the files to do some linking tasks with
`ln'.
But it keeps giving me the following error message:
timed-out waiting for login prompt at test_telnet.pl line 14
It just can't detect the login prompt... the login prompt should be like
this when I manually connect at command prompt
login:_
where _ is the cursor.
I've already tried setting the Prompt attribute of either new() or login()
or both to exactly how it looks like or even '//', it still couldn't match.
I've also disable the Timeout to make sure it has enough time, still.
Attached is the dump file, it shows that the remote server hadn't even sent
out the login prompt yet... so the input.log is empty. What happened??
If I changed the server and login info to connect to another server, it
works fine.
Could somebody help me?? Thanks.
##########################################################################
use strict;
use Net::Telnet;
use constant FTP_SERVER => 'some.proxy';
use constant USERNAME => 'userid';
use constant PASSWORD => 'password';
my $telnet;
my $basepath = "/ps/products/hello/world";
my @output;
$telnet = Net::Telnet->new(Dump_Log => "dump.log",
Input_log => "input.log");
$telnet->open(FTP_SERVER);
$telnet->login(Name => USERNAME, Password => PASSWORD);
$telnet->cmd("cd /home/ftp$basepath");
# trial
@output = $telnet->cmd("ls -lF");
$telnet->close();
print "@output\n";
begin 644 dump.log
M/"`P>#`P,#`P.B!F9B!F8R`R-"`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@__PD#0H-"CP@,'@P,#`P,#H@9F8@9F0@,3@@
M9F8@(&9E(#(T("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@(/_]
M+O_^)`T*#0H^(#!X,#`P,#`Z(&9F(&9C(#$X("`@("`@("`@("`@("`@("`@
A("`@("`@("`@("`@("`@("`@("`@("`@("#__"X-"@T*
`
end
------------------------------
Date: Fri, 16 Mar 2001 01:03:39 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: pattern matching
Message-Id: <3ab16451.63186215@news.erols.com>
On Thu, 15 Mar 2001 22:17:54 -0000, "Milliwave"
<milliwave@rfengineering.freeserve.co.uk> wrote:
>interpreter complains about an uninitilized variable.
For more informative warnings, tack the line 'use diagnostics;' at the
beginning of your code.
perldoc diagnostics
perldoc perldiag
>I would also apprecite if you could inform me how to declare variables
>locally and globally?
perldoc -f my
perldoc -f our
>m/^P\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\d*|-\d*)/)
[regex train wreck truncated]
>IS there anyway to shrink the $_ =~ pattern
Most certainly, but it's not worth the effort when it's mostly
duplicating the function of 'split'. The best thing would be to put a
bullet in its head and bury it in the back yard.
>It should be able to detect both +ve and negative numbers,
>and I don't want to assign "ANY" semi-colons present at the end of the
>P patterns to variables like $1 $2 etc
+ve? If you mean 'positive' say 'positive'. Stop abbreviating.
Try this.
1. Simultaneously test for 'P' and eliminate it.
if ( $_ =~ s/^P\s*// ) {...
2. Strip any semicolons.
$_ =~ s/;//g;
3. Split on whitespace.
my @nums = split /\s+/, $_;
4. Use $nums[0] wherever you would use $1, $nums[1] wherever you would
use $2, etc.
>If I have two spearate while loops does while loop no execute first,
>and then while loop2?
>while(loop1) { }
>while(loop2) { }
The question is difficult to parse. More abbreviation difficulties.
The first loop must complete before the second can begin. Unless the
'while(...)' condition is false to begin with, in which case the {...}
block is completely ignored.
Did you expect the program flow magically jump back and forth between
the two?
------------------------------
Date: Fri, 16 Mar 2001 01:30:54 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Perl 4
Message-Id: <slrn9b2r6e.nts.mgjv@verbruggen.comdyn.com.au>
[Please, in the future, put your reply _after_ the suitably trimmed
text you reply to. It's the generally accepted convention on this
group, and Usenet in general.]
On Thu, 15 Mar 2001 14:59:40 +0100,
Kiwitter@qns.de <kiwitter@qns.de> wrote:
> "Martien Verbruggen" <mgjv@tradingpost.com.au> schrieb im Newsbeitrag
> news:slrn9b1439.kjn.mgjv@martien.heliotrope.home...
>> On Thu, 15 Mar 2001 10:33:44 +0100,
>> Kiwitter@qns.de <kiwitter@qns.de> wrote:
>> >
>> > where can i get Perl 4 for Linux ? can some one tell me the URL
>> > of an server wherer i can download perl 4 ?
>>
>> Anyway, you can download the sources from any CPAN mirror,
>
> no my os is System V unix :-)
Euhmm.. And you're looking for a linux binary?
Anyway, your question prompted me to try to get the hints for perl4 on
Linux correct again yesterday. unfortunately there was more needed
than just a few hints. I've been able to compile it, and get it to
pass all the tests (had to change the tests that used a glob, because
of ordering problems). Still have to make sure socket-related stuff
works.
Is there any interest in this stuff, purely for hstorical reasons?
Should I dump it on CPAN as a diff?
Martien
--
Martien Verbruggen |
Interactive Media Division | I'm just very selective about what I
Commercial Dynamics Pty. Ltd. | accept as reality - Calvin
NSW, Australia |
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 498
**************************************