[11985] in Perl-Users-Digest
Perl-Users Digest, Issue: 5585 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 6 16:07:08 1999
Date: Thu, 6 May 99 13:00:19 -0700
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, 6 May 1999 Volume: 8 Number: 5585
Today's topics:
Re: "learning perl" does not seem to be written well <dchristensen@california.com>
Re: ==> REGEX, how do I use a variable as a seach patte (Fuzzy Warm Moogles)
Re: ==> REGEX, how do I use a variable as a seach patte (Larry Rosler)
Re: a tail of two hashes (Tad McClellan)
Re: Can a DNS lookup be performed from within perl ? <johndoe@this.is.a.bogus.address.com>
Re: DATE PROBLEM <aqumsieh@matrox.com>
Get ID of who has file open? <kenneth.r.ralph@boeing.com>
How do I practice scripts? <lauriedu@globalnet.co.uk>
Re: How do I practice scripts? <purselj@primenet.com>
Re: how to round off numbers? (Bart Lateur)
Re: how to round off numbers? (Bart Lateur)
Re: how to round off numbers? <t-armbruster@ti.com>
Re: how to round off numbers? <hunt@queen.es.hac.com>
Re: how to round off numbers? <hunt@queen.es.hac.com>
Re: Increment a variable's name <emschwar@rmi.net>
Re: Modulo (Larry Rosler)
Re: Modulo (Larry Rosler)
Re: OReilly bullshit.... Camel logo trademark <gellyfish@gellyfish.com>
Re: Pentium III Chips Released with IDs - Intel won't b (Larry Rosler)
Re: Please Help <gellyfish@gellyfish.com>
Re: Problem with Net::Telnet and its output <jay@rgrs.com>
Re: procedure to convert sec to HH:MM:SS format <acl@cyberdeck.net>
Re: question on regex... <tye@metronet.com>
Re: Slice [N..end] of unnamed array? <aqumsieh@matrox.com>
Re: split, pop, and cut <aqumsieh@matrox.com>
Re: using $, (was Re: having problems) <uri@sysarch.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 6 May 1999 12:39:00 -0700
From: "David Christensen" <dchristensen@california.com>
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <3731edea@news2.newsfeeds.com>
Mike:
I also started down the Perl path recently. Two things I found to
be critical were: the platform I was using and adequate skills on
that platform. On a Linux box with basic to intermediate skills,
everything worked great.
I suggest you go down the Linux path a little ways, far enough to
set up a bone-stock installation. Get and read Peek, Todino, &
Strang, 1998, "Learning the UNIX Operating System", 4 ed., O'Reilly
& Associates. Also read any book that comes with your Linux
distribution (I use RedHat).
Next, figure out which editor you're going to use. Get and read
the O'Reily learning book on it (I use vi).
An option at this point would be the O'Reily learning book for your
shell of choice (I use bash).
You should then find Perl a whole lot easier.
--
David Christensen
dchristensen@california.com
mikecard@my-dejanews.com wrote in message
<7g1o7q$94d$1@nnrp1.dejanews.com>...
>hi
>...
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Thu, 06 May 1999 19:06:35 GMT
From: tgy@chocobo.org (Fuzzy Warm Moogles)
Subject: Re: ==> REGEX, how do I use a variable as a seach pattern
Message-Id: <3734e80f.16391741@news.oz.net>
On Thu, 6 May 1999 07:48:12 -0700, lr@hpl.hp.com (Larry Rosler) wrote:
>In article <37374547.5208098@news.skynet.be> on Thu, 06 May 1999
>07:42:17 GMT, Bart Lateur <bart.lateur@skynet.be> says...
>>
>> $search= "<-(*.?)->|<\\+(*.?)\\+>";
>
>It is easier to read (hence less error-prone) if you use single quotes
>and single backslashes:
>
> $search= '<-(*.?)->|<\+(*.?)\+>';
I sometimes find comfort in forward slashes:
$search = qr/<-(*.?)->|<\+(*.?)\+>/;
It hints that there is a RE pattern in there and not just a string of
punctuations.
--
Fuzzy | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=
------------------------------
Date: Thu, 6 May 1999 12:41:20 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: ==> REGEX, how do I use a variable as a seach pattern
Message-Id: <MPG.119b903e82cfc4a79899e4@nntp.hpl.hp.com>
In article <3734e80f.16391741@news.oz.net> on Thu, 06 May 1999 19:06:35
GMT, Fuzzy Warm Moogles <tgy@chocobo.org> says...
> On Thu, 6 May 1999 07:48:12 -0700, lr@hpl.hp.com (Larry Rosler) wrote:
> >In article <37374547.5208098@news.skynet.be> on Thu, 06 May 1999
> >07:42:17 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> >> $search= "<-(*.?)->|<\\+(*.?)\\+>";
> >
> >It is easier to read (hence less error-prone) if you use single quotes
> >and single backslashes:
> > $search= '<-(*.?)->|<\+(*.?)\+>';
>
> I sometimes find comfort in forward slashes:
> $search = qr/<-(*.?)->|<\+(*.?)\+>/;
>
> It hints that there is a RE pattern in there and not just a string of
> punctuations.
As if it could be anything else, except line noise. :-)
Provided you have the luxury of all your programs running on perl 5.005.
I don't. Some of mine run on perl 5.002, 5.003 and 5.004. I finally
stamped out 5.001 on one of the (internal HP, blush) servers a while
ago.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 6 May 1999 10:42:32 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: a tail of two hashes
Message-Id: <oo9sg7.f67.ln@magna.metronet.com>
roreilly@oxhp.com wrote:
: I have written a couple of subroutines that return hashes.
: %dmn = domain();
: %dmnid = domainID();
: domain() returns $domainnameID{domainname}
: domainID() returns $databaseid{domainnameID}
So then, your subroutines do NOT return hashes.
They return scalars. (dollar sign means scalar in Perl).
Don't you get warnings like "Odd number of elements in hash assignment"?
Where is the code for the subroutines?
: I am trying to construct another hash that contains:
: databaseid{domainname}
: by binding the two hashes on the common domainnameID.
: I have just ventured into the world of hashes and appreciate any help.
Your question doesn't make any sense to me.
Try posting a short and complete Perl program, describe what it
does, describe what you want it to do instead.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 6 May 1999 20:56:37 +0200
From: "John Doe" <johndoe@this.is.a.bogus.address.com>
Subject: Re: Can a DNS lookup be performed from within perl ?
Message-Id: <7gsou2$pja$1@news.inet.tele.dk>
This doesn't work for winnt, though, since gethostbyaddr isn's supported. Is
there another way of getting the hostname of someone? (I know this might be
off topic, but I've already asked in several other newgroups, without
getting any answers....)
Send replies to usenet@sitemakerz.dk and/or post them to the group...
Thanks
David Efflandt <efflandt@xnet.com> wrote in message
news:slrn7j1t0c.he.efflandt@efflandt.xnet.com...
> On 22 Apr 1999 07:01:56 GMT, Uri Raz <uraz@iil.intel.com> wrote:
> > I'm working on a perl script that analyses a web server's log file.
> >
> > As part of the script I want to translate an IP address into a host's
> > name, using (reverse) DNS lookup.
> >
> > Is there a way to do this from within perl, as a function and not by
> > calling a shell to perform nslookup ?
>
> # Get remote host if server does not
> unless ($ENV{REMOTE_HOST} && $ENV{REMOTE_ADDR} ne $ENV{REMOTE_HOST}) {
> my $ip_num = pack("C4", split(/\./, $ENV{REMOTE_ADDR}));
> $ENV{REMOTE_HOST} = scalar gethostbyaddr($ip_num, 2);
> $ENV{REMOTE_HOST} = $ENV{REMOTE_ADDR} unless $ENV{REMOTE_HOST};
> }
>
> Apache used to set REMOTE_HOST = REMOTE_ADDR if server was set to NOT
> resolve hostnames. However, in recent versions there is no REMOTE_HOST
> unless apache is set to resolve hostnames.
>
> >--
> >
+---------+---------------------------+---------------------------------+
> > | Uri Raz | mailto:uraz@iil.intel.com | I speak for myself, not Intel.
|
> > | Work is what employees do while managers lay down the work plans. ;-)
|
> > | My home page <URL:http://www.private.org.il>
|
> >
+-----------------------------------------------------------------------+
>
>
> --
> David Efflandt efflandt@xnet.com
> http://www.xnet.com/~efflandt/
------------------------------
Date: Thu, 6 May 1999 13:11:41 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: DATE PROBLEM
Message-Id: <x3yhfpqdsxe.fsf@tigre.matrox.com>
bababozorg@aol.com writes:
> can you please tell me how can i find out if the date i have is later than
> today or earlier. for example:
> i have the date 31-5-99
> and i want to know if i have passed this date or not.
> i mean if i check it when my date is 01-6-99 the program should tell me the
> date is over (passed)
> can you plase tell me how to do it?
Ever heard of the Y2K millenium bug ? ;-)
------------------------------
Date: Thu, 6 May 1999 18:42:41 GMT
From: Ken Ralph <kenneth.r.ralph@boeing.com>
Subject: Get ID of who has file open?
Message-Id: <3731E2A1.25B4C93E@boeing.com>
Any suggestions on how to ID who has a file opened for write on an NT
server?
TIA,
ken
------------------------------
Date: Thu, 6 May 1999 20:12:55 +0100
From: "Laurie Dunn" <lauriedu@globalnet.co.uk>
Subject: How do I practice scripts?
Message-Id: <7gspgm$ks3$1@gxsn.com>
This is a multi-part message in MIME format.
------=_NextPart_000_0064_01BE97FC.D3C4DEC0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I am new to perl and want to practice scripts.
My ISP will not let me store scripts.=20
I have a windows PC and a standard dial up connection.
How does anybody suggest I can write, send and call my scripts=20
so that I can practice?
Thanks in advance for your comments
Laurie
------=_NextPart_000_0064_01BE97FC.D3C4DEC0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>
<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.2106.6"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 size=3D2>I am new to perl and want to =
practice=20
scripts.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>My ISP will not let me store =
scripts.=20
</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>I have a windows PC and a standard =
dial up=20
connection.</FONT></DIV>
<DIV><FONT size=3D2>How does anybody suggest I can write, send and call =
my scripts=20
</FONT></DIV>
<DIV><FONT size=3D2>so that I can practice?</FONT></DIV>
<DIV><FONT size=3D2>Thanks in advance for your comments</FONT></DIV>
<DIV><FONT size=3D2>Laurie</FONT></DIV></BODY></HTML>
------=_NextPart_000_0064_01BE97FC.D3C4DEC0--
------------------------------
Date: Thu, 06 May 1999 13:40:06 -0700
From: John <purselj@primenet.com>
Subject: Re: How do I practice scripts?
Message-Id: <3731FE26.42A51C9@primenet.com>
--------------BFCB1C1D599B5405830AB684
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
why not just run perl on your pc and practice away ;)
Laurie Dunn wrote:
> I am new to perl and want to practice scripts.My ISP will not let me
> store scripts.I have a windows PC and a standard dial up
> connection.How does anybody suggest I can write, send and call my
> scriptsso that I can practice?Thanks in advance for your
> commentsLaurie
--------------BFCB1C1D599B5405830AB684
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
why not just run perl on your pc and practice away ;)
<p>Laurie Dunn wrote:
<blockquote TYPE=CITE> <font color="#000000"><font size=-1>I am new
to perl and want to practice scripts.</font></font><font color="#000000"><font size=-1>My
ISP will not let me store scripts.</font></font><font color="#000000"><font size=-1>I
have a windows PC and a standard dial up connection.</font></font><font size=-1>How
does anybody suggest I can write, send and call my scripts</font><font size=-1>so
that I can practice?</font><font size=-1>Thanks in advance for your comments</font><font size=-1>Laurie</font></blockquote>
</body>
</html>
--------------BFCB1C1D599B5405830AB684--
------------------------------
Date: Thu, 06 May 1999 19:10:28 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: how to round off numbers?
Message-Id: <3738e90d.2608717@news.skynet.be>
Cim wrote:
>>What happens if you do this:
>>
>> printf("%.0f %.0f\n",$number1,$number2);
>>
>>With your example numbers for instance ?
>>
>
>mhm, yea but that will print. what if I have to use those numbers in
>other functions etc.
Then use
sprintf
instead.
Bart.
------------------------------
Date: Thu, 06 May 1999 19:11:44 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: how to round off numbers?
Message-Id: <3739e933.2646945@news.skynet.be>
Tom Christiansen wrote:
>A newsgroup is not a manpage server. man perlfunc, search for sprintf.
Apparently, judging from the new batch of PERLFUNC posts (YOUR posts),
it is. :-)
Bart.
------------------------------
Date: Thu, 6 May 1999 14:21:36 -0500
From: "Tim Armbruster" <t-armbruster@ti.com>
Subject: Re: how to round off numbers?
Message-Id: <%0mY2.47$zh2.2758@dfw-service1.ext.raytheon.com>
David Cassell wrote in message <3731D80F.44ABB570@mail.cor.epa.gov>...
>Tim Armbruster wrote:
>>
>>
>> Add .5 to your number
>
>No no no no no. Umm, did I say `no'? :-)
>
Yes, several times.
>Please don't do that. It doesn't handle the `integer+0.5' case
>correctly in half the cases. Now if the probability of such a case
>occurring in *your* application is zero, then fine, go ahead.
>But sprintf is The Right Way here, and should be added to everyone's
>toolbox anyway. Rounding off numbers is a good way to learn about
>some of the power of sprintf() too.
>
OK, advice taken.
------------------------------
Date: Thu, 06 May 1999 12:29:25 -0700
From: KC <hunt@queen.es.hac.com>
Subject: Re: how to round off numbers?
Message-Id: <3731ED95.6BE36C78@queen.es.hac.com>
Cim wrote:
> mhm, yea but that will print. what if I have to use those numbers in
> other functions etc. IS there a function that rounds numbers normally
> or is there not?
$num = int($num * 1000 + .5) / 1000
will turn $num=3.45238576
into $num=3.452
--
-----
KC
------------------------------
Date: Thu, 06 May 1999 12:34:29 -0700
From: KC <hunt@queen.es.hac.com>
Subject: Re: how to round off numbers?
Message-Id: <3731EEC5.54AF3F52@queen.es.hac.com>
Tom Christiansen wrote:
> A newsgroup is not a manpage server. man perlfunc, search for
> sprintf.
>
> Bye.
Isn't it? People have questions. They post questions on the ng. Other
people answer those questions.
Oh...you must be one of those all-knowing geniuses that only uses the ng
to post examples of their brilliance.
--
-----
KC
------------------------------
Date: 06 May 1999 13:33:42 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Increment a variable's name
Message-Id: <xkfaevim1rd.fsf@valdemar.col.hp.com>
Tom Pape <tom@ernieball.com> writes:
> Is there a way I can increment a variable's name? The form I am
> processing can have a different number of quantity variables depending
> on the number of items listed. If I have $i number of items can I
> assign values to a variable that might look like qty$i? I need to
> incerment the variables name by 1 each time a loop runs, for example:
> qty1, then qty2, then qty3 ....
You almost *never* want to do that. Really. This is known as "symbolic
references", and you can search DejaNews on clpm for articles by Tom
Christiansen on why this is a Bad Thing(tm); I'm not going to go into
detail.
There are two possible alternatives I know of:
1) If you know you're going to index by number, then why not just use an
array?
$qty[1] = "something";
$qty[2] = "something else";
and so on.
2) If not, then you should be using a hash, instead:
foreach $i (0..9) {
$hash{"qty$i"} = "something$i";
}
Using CGI.pm, if you aren't already, will make either of these options
easier.
-=Eric
------------------------------
Date: Thu, 6 May 1999 12:12:08 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Modulo
Message-Id: <MPG.119b89671c657f9f9899e1@nntp.hpl.hp.com>
In article <3730F944.D9E75B4E@frontiernet.net> on Wed, 05 May 1999
22:07:01 -0400, Bob Walton <walton@frontiernet.net> says...
> Hmm...Standard C (Plauger & Brodie) states that the C operator % computes the
> remainder. Perl (see perlop) states that it computes the modulus. These are
> not the same thing. If you want perl to compute something like C does with
> negative numbers, make the second one negative, not the first one.
I wonder why people answer posts like this without reading (and even
quoting, as I shall) the documentation.
For ANSI/ISO Standard C:
"... the result of the % operator is the remainder. ... If either
operand is negative, whether the result of the / operator is the largest
integer less than or equal to the algebraic quotient or the smallest
integer greater than or equal to the algebraic quotient is
implementation-defined, as is the sign of the result of the % operator."
In standards-speak, "implementation-defined" means whatever the compiler
writer chooses (usually what the hardware gives), and the documentation
of the compiler must specify what you get. In other words, it is not
portable.
For Perl (from perlop):
"Binary ``%'' computes the modulus of two numbers. Given integer
operands $a and $b: If $b is positive, then $a % $b is $a minus the
largest multiple of $b that is not greater than $a. If $b is negative,
then $a % $b is $a minus the smallest multiple of $b that is not less
than $a (i.e. the result will be less than or equal to zero). Note than
when *use integer* is in scope, ``%'' give you direct access to the
modulus operator as implemented by your C compiler. This operator is not
as well defined for negative operands, but it will execute faster."
So Perl provides either of two results: the modulus (as defined
explicitly and portably in the documentation), and the C 'remainder'
(which is implementation-defined and not portable).
Perl is great! (And very well documented, too, despite my recent
diatribes about Unix bigotry.)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 6 May 1999 12:31:58 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Modulo
Message-Id: <MPG.119b8e09ce732f839899e2@nntp.hpl.hp.com>
In article <3731C773.A05F9636@mail.cor.epa.gov> on Thu, 06 May 1999
09:46:43 -0700, David Cassell <cassell@mail.cor.epa.gov> says...
> [1] This post is actually irrelevant to c.l.p.misc, and should
> have gone to one of the sci.math groups instead.
No, it's quite relevant to Perl. See my other post in this thread.
> [2] Don't let TomC or Uri find out that some BillWare gives the
> same answer as Perl, where PHP doesn't. :-)
Perl can give portable or non-portable results, as I said. BillWare
exists in its own universe, so portability is a meaningless concept.
:-<
PHP was a new one on me (maybe because I don't use databases). And it's
up to version 3.0.7 ! I couldn't find any statements about arithmetic
in their documentation.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 5 May 1999 22:01:01 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: OReilly bullshit.... Camel logo trademark
Message-Id: <7gqf2t$3r7$1@gellyfish.btinternet.com>
On Wed, 05 May 1999 22:14:01 +0200 William Blasius #42722 wrote:
>
> I don't see any notifications on my copy of the Camel which notifies the
> connection betwen Perl and the camel
On the page with all the legal stuff facing the first page of the Table
Of Contents (in the second edition not the first) :
The use of a camel image in association with the Perl Language is a
trademark of O'Reilly & Associates Inc. Permission may be granted
for non-commercial use; please inquire by sending mail to camel@ora.com.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Thu, 6 May 1999 12:37:49 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Pentium III Chips Released with IDs - Intel won't budge
Message-Id: <MPG.119b8f6bcc51cbde9899e3@nntp.hpl.hp.com>
In article <3731cf35.68486969@news.ultranet.com> on Thu, 06 May 1999
17:57:11 GMT, Sean Murphy <smurphy*NOSPAM*@schange.com> says...
whatever
HEY, YOU ALL! STOP RESPONDING TO THIS SPAM IN ALL THESE NEWSGROUPS!
Sheesh!!!
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 5 May 1999 22:08:12 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Please Help
Message-Id: <7gqfgc$3ra$1@gellyfish.btinternet.com>
On Wed, 05 May 1999 18:20:21 +0000 Steven Scoleri wrote:
> I'm sorry actually my example is bad it actually does work. The problem
> is when i do something like this:
>
>
> open(QUE,"$queue") || die "Queue is broken: $! \n";
> while(<QUE>) {
>
chomp;
> ($name,$sex,$patient_id,$series_id,$image_number,$images_in_acq,$modality,$file)=split(":");
<snip>
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 06 May 1999 15:36:41 -0400
From: Jay Rogers <jay@rgrs.com>
Subject: Re: Problem with Net::Telnet and its output
Message-Id: <824slqj8hi.fsf@shell2.shore.net>
"Tom Ashbrook" <tashbrook@edisonenterprises.com> writes:
> The problem is that the output from the uptime command is there on some runs
> and not there on others BUT ONLY FOR THE AIX boxes. The HP servers don't
> have a problem with it and the output is there every time. I have tried to
> run the same command three times in a row and still no output sometimes and
> other times there is. Anyone know what this might be?
[snip]
> $dino = new Net::Telnet (Host => "@_",
> Timeout => 30,
> Prompt => '/.*>/');
^^^^^^
That prompt will match everything that's been read up until the
last '>' char, which in some cases will be the entire output of
the command. That won't leave much output to be returned to you.
--
Jay Rogers
jay@rgrs.com
------------------------------
Date: Thu, 06 May 1999 21:10:40 +0200
From: acl <acl@cyberdeck.net>
Subject: Re: procedure to convert sec to HH:MM:SS format
Message-Id: <3731E930.2C6E5094@cyberdeck.net>
Juho Cederstrom wrote:
> On Wed, 05 May 1999 15:29:38 +0200,
> peter <godzila@freemail.nl> wrote:
>
> > Can some one tell me how can I convert sec to a normal time format
> > hh:mm:ss.
>
> my @time = gmtime( $seconds );
> my $formatted =
> sprintf( "%02d:%02d:%02d", $time[2], $time[1], $time[0] );
>
> You can't use localtime instead of gmtime, because that won't give you
> correct results if you don't live in GMT.
You can even :
use Time::CTime;
$d = ctime(time);
print($d);
=> Thu May 6 21:07:44 1999
The doc tells you how to get hh:mm:ss
(I think you can find it in Time-modules )
------------------------------
Date: 6 May 1999 14:40:50 -0500
From: Tye McQueen <tye@metronet.com>
Subject: Re: question on regex...
Message-Id: <7gsr82$76p@fumnix.metronet.com>
) Tye McQueen <tye@metronet.com> says...
) > In this case, I think it would be better to use substr():
) >
) > @matches = grep $test eq substr($_,0,length($test)), @grouplist;
)
lr@hpl.hp.com (Larry Rosler) writes:
) #!/usr/local/bin/perl -w
) use strict;
) use Benchmark;
)
) my $front = 'matchstring' . 'x' x 50;
) my $back = 'x' x 50 . 'matchstring';
) my $none = 'x' x 61;
) my $match = 'matchstring';
You've stacked the deck in index()s favor. To see why I think
substr() _should_ be faster than index(), I prefer:
) my $front = 'matchstring' . 'match' x 50;
) my $back = 'match' x 50 . 'matchstring';
) my $none = 'match' x 52;
) my $match = 'matchstring';
But your benchmarks appear to indicate that
$sub eq substr($str,0,length($sub))
isn't highly optimized by Perl. It is probably calling malloc()
[to create a temporary SV] while index() doesn't.
) There Are Three Ways To Do It (at least), and it's hard to choose among
) them based on speed. There are many dependencies on string lengths and
) match probabilities.
I think substr() provides the best performance in the worst cases
so I'd choose it (in the best cases, the time is small enough it
doesn't really matter). It is O( length($substring) ).
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: Thu, 6 May 1999 14:18:49 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Slice [N..end] of unnamed array?
Message-Id: <x3yg15adptj.fsf@tigre.matrox.com>
sam@cs.stir.ac.uk (Sam Nelson) writes:
> If I just generated an array whose length I don't know, how do I take a slice
> containing item N onwards?
@array[$N..$#array];
> Obviously I can put the slice into an intermediate
> array (@Temp, say) and slice `@Temp[$N..-1]' or something like that but while
> the syntax makes sense, a slice like `(split(':'))[$N..-1]' always seems
> to get me nothing at all. Is there some obvious reason I'm missing why this
> can't work, or should I be doing this some other way, or must I simply use the
> named temporary?
It doesn't work because the .. operator works only one way. In a
statment like:
@ar[3..-1];
The list [3..-1] is evaluated FIRST. But, this evaluates to an empty
list since the range operator can only count upwards. So, you are
taking an *empty* slice of @ar, which is, er, empty!
HTH,
Ala
------------------------------
Date: Thu, 6 May 1999 14:46:59 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: split, pop, and cut
Message-Id: <x3yemkudoil.fsf@tigre.matrox.com>
Peter Eisengrein <prsinfo@profrecovery.com> writes:
> I am looking for a way to split not by delimiter (which is like the UNIX
> 'cut -d'), but instead by character count, like the UNIX 'cut -c'
> command. I know I can cut off the end with pop, but that isn't exactly
> right either.
pop? Are you talking about arrays or strings? You can only split()
strings, not arrays. You can only pop() arrays, not strings. What
exactly are you trying to "split"?
If you want to manipulate array elements, then look into the following
functions:
shift
unshift
push
pop
splice
If you want to manipulate strings, then look into the following
functions:
index
rindex
Moreover have a look at the perlre documentation for some info on
regular expressions.
> I can't find this anywhere in the man pages or on the Web. Any help you
> can offer is greatly appreciated. Thanks.
I have the feeling that you don't really know what you're looking for,
that's why you can't find it :)
Look into what I mentioned above, and if you still have any questions,
then ask again. And be more specific.
HTH,
Ala
------------------------------
Date: 06 May 1999 15:23:10 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: using $, (was Re: having problems)
Message-Id: <x7g15avw81.fsf@home.sysarch.com>
>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:
BL> Uri Guttman wrote:
BL> The benchmark I just posted in the original thread, seems to indicate
BL> that $, is indeed a bit faster than join, which in it's turn is still
BL> slower than "@data" (using $").
BL> That's what I would expect. { print @data } does NOT require
BL> construction of the whole string. Instead, it can print out one array
BL> item at a time. Therefore it can be faster.
i seem to recall join was faster. i will have to reread the
benchmark. can you post it again or email it to me?
>> so what advantage does it have over join unless you want all output to
>> have $, used?
BL> Readbility. I think
BL> print @data;
BL> looks a LOT less horrible (and is therefore less error-prone) than
BL> print join("\t",@data)."\n";
you forgot the "\n", on yours which if you added it, would output a
blank field. so that is not clear to me. also the code to set and unset
$, (a local in a block or whatever) is confusing too and omitted by yoor
example. my line is self contained. and i do it with , and not .
only when i output a line to the tabbed file do i need to do that and it
is very obvious what is going on. a hidden $, use is more obscure IMO.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 5585
**************************************