[16452] in Perl-Users-Digest
Perl-Users Digest, Issue: 3864 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 31 21:05:27 2000
Date: Mon, 31 Jul 2000 18:05:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <965091915-v9-i3864@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 31 Jul 2000 Volume: 9 Number: 3864
Today's topics:
DBI:: UPDATE format (Perl DBI O'Reilly fails to explain <linux@worsdall.demon.co.uk>
execute a Perl script in another Perlscript johands@hotmail.com
Re: execute a Perl script in another Perlscript <tina@streetmail.com>
forking and child processes (matt venn)
Help making PPD <al@blackthornesw.com>
Re: How to print the thousands comma for financial numb <bart.lateur@skynet.be>
Re: How to recognize triplicates <tim@ipac.caltech.edu>
Re: How to recognize triplicates (Craig Berry)
Re: How to recognize triplicates <tina@streetmail.com>
Re: How to recognize triplicates <tina@streetmail.com>
Re: How to recognize triplicates (Craig Berry)
Open FILEs <hxshxs@my-deja.com>
Re: Open FILEs <dietmar.staab@t-online.de>
Re: Open FILEs <tina@streetmail.com>
Re: Parse::RecDescent with left-recursive grammar. (Damian Conway)
Re: Perl and MySQL (Keith Calvert Ivey)
Re: Please unconfuse me.... if (<>)... <sumus@aut.dk>
Possible regex regression in 5.6.0 <dsh@mvps.org>
Re: printf %e exponent digits <lr@hpl.hp.com>
Re: question about a Regular Expression (Abigail)
question about the insert sql command. <stevep@oz.net>
Re: Quotes in regex? (Christian Kaufhold)
Re: Rounding numbers in Perl <ronnie@catlover.com>
Re: Rounding numbers in Perl <rschram@reed.edu>
Re: Rounding numbers in Perl <lr@hpl.hp.com>
Re: Rounding numbers in Perl (Logan Shaw)
Re: Rounding numbers in Perl (Logan Shaw)
Re: Running other programs in background <bart.lateur@skynet.be>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 1 Aug 2000 00:00:26 +0100
From: Mark Worsdall <linux@worsdall.demon.co.uk>
Subject: DBI:: UPDATE format (Perl DBI O'Reilly fails to explain properly)
Message-Id: <e9Lb4WAKUgh5EwUH@worsdall.demon.co.uk>
Hi,
is this wrong:-
$sth = $dbh->prepare("UPDATE counter FROM wizSearches WHERE ID =
$chkfound");
$sth->execute();
err, uhm, where do things go?
wizSearches is the name of the MySQL table
The record to update is ID (the value of $chkfound)
This record contains a table field called counter
$searchCounter contains the value to stick in the field counter.
a) I can't get the syntax right
b) where do I stick the new value $searchCounter
I have Perl DBI, but strangely it only tells you how to do updates from
the command line?
--
He came from Econet - Oh no, I've run out of underpants :(
Home:- jaydee@wizdom.org.uk http://www.wizdom.org.uk
Shadow:- webmaster@shadow.org.uk http://www.shadow.org.uk
Work:- netman@hinwick.demon.co.uk http://www.hinwick.demon.co.uk
Web site Monitoring:- http://www.shadow.org.uk/SiteSight/
------------------------------
Date: Mon, 31 Jul 2000 22:28:48 GMT
From: johands@hotmail.com
Subject: execute a Perl script in another Perlscript
Message-Id: <8m4uiq$kc0$1@nnrp1.deja.com>
hello everybody
how do i execute an cgi-script(written in Perl) within another cgi-
script (written in Perl).
So i have a cgi-script and then somewhere in this cgi-script i want
another cgi-script to be executed.
nice greetings and thank you
johan
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 31 Jul 2000 22:53:21 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: execute a Perl script in another Perlscript
Message-Id: <8m5011$5mcr3$11@ID-24002.news.cis.dfn.de>
hi,
johands@hotmail.com wrote:
> how do i execute an cgi-script(written in Perl) within another cgi-
> script (written in Perl).
> So i have a cgi-script and then somewhere in this cgi-script i want
> another cgi-script to be executed.
what do you mean with 'executed'?
you can do this in many ways. depends on
what you want, e.h. if you want to pass
parameters to the script, and do that
with POST or get, ...
you can do a redirect, you can do exec,
you can do system, or you can use one
of the LWP modules.
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
please no answers via email unless followup is set to poster.
------------------------------
Date: Mon, 31 Jul 2000 22:18:20 GMT
From: matt@NOSPAMcipherdesign.com (matt venn)
Subject: forking and child processes
Message-Id: <3985e1d9.45041866@news.ntlworld.com>
hey all,
im trying to get to grips with forking child processes with perl.
i have a number of questions that the perldoc and my books havent
answered:
1) how do i make sure that if my parent process is killed, it takes
its children with it? would i assign a relevant handler to SIG{} to
kill the children?
ive read the man pages on kill, and it doesnt seem to kill any child
processes, so in the normal case do the children just get handed over
to init?
2) i have noticed that if my parent is sleeping, and a child dies
(assuming i have set up a 'reaper' sub); the sleep is interrupted, and
when normal execution resumes, the sleep is not finished. how could i
overcome this? is this actually not a problem in reality because its
unlikely for the parent to need to sleep for a specific amount of
time?
thanks matt.
<still working on a decent signature...>
------------------------------
Date: Mon, 31 Jul 2000 17:40:15 -0400
From: Al <al@blackthornesw.com>
Subject: Help making PPD
Message-Id: <ltqbosop4hqpdddau13oojujoamh46pf9u@4ax.com>
I can't seem to find this answer anywhere.
Using ActivePerl build 616 & Win98
I followed the directions at ActiveState to make a ppd. This is what I
get:
extracted the tar.gz (for the Win32-ASP package, incidentally) to
C:\Win32-ASP.
using 4dos prompt:
C:\Win32-ASP> perl makefile.pl
Checking if your kit is complete...
Looks good
Bad command or file name
Bad command or file name
Unable to find a perl 5 (by these names: C:\Perl\bin\Perl.exe
miniperl perl perl5 perl5.6.0, in these dirs: C:\WINDOWS
C:\WINDOWS\COMMAND C:\BIN C:\WINDOWS C:\WINDOWS\COMMAND C:\PERL\BIN
C:\PROGRA~1\NETWOR~1\MCAFEE~1 "C:\PROGRAM FILES\MTS" C:\Perl\bin)
Writing Makefile for Win32::ASP
Well, duh, perl's right there in c:\perl\bin, otherwise the stupid
thing wouldn't start in the first place. Maybe it's the long path and
4dos. So, i shorten the path to just the perl dir and c:\bin, where i
have the misc tools (nmake, tar, gzip). Then, I execute the same
command from a plain COMMAND.COM prompt:
C:\Win32-ASP> perl makefile.pl
Checking if your kit is complete...
Looks good
Unable to find a perl 5 (by these names: C:\Perl\bin\Perl.exe
miniperl perl perl 5 perl5.6.0, in these dirs: C:\BIN C:\PERL\BIN
C:\Perl\bin)
Writing Makefile for Win32::ASP
The resulting makefile is obviously broken:
C:\Win32-ASP> nmake
Microsoft (R) Program Maintenance Utility Version 1.50
Copyright (c) Microsoft Corp 1988-94. All rights reserved.
NMAKE : fatal error U1081: '0' : program not found
Stop.
So, which dead chicken do I wave over it, in what pattern?
I've got GNU make on here too, from the mingw32 stuff, if that would
help.
------------------------------
Date: Tue, 01 Aug 2000 00:24:51 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How to print the thousands comma for financial numbers ( $ 12,8292.75)
Message-Id: <r56cosgthsf32vecoalu6s0asmrfcmo1qf@4ax.com>
>> Louis Banens (louis.banens@xs4all.nl) wrote:
>> : I cannot find out how to print the thousands comma for financial numbers
>( $ 12,8292.75).
That's a weird convention.
--
Bart.
------------------------------
Date: Mon, 31 Jul 2000 16:05:27 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: How to recognize triplicates
Message-Id: <39860637.BFE67588@ipac.caltech.edu>
stillanewbie@db-networks.com wrote:
>
> How to recognize 3 times the same character or the same number?
>
> ie: 000 or 111 or AAA or ZZZ
>
> I have tried but: m/\D{3,}/ will match any 3 numbers in a row, not
> identical numbers
As others have said, '/(\d|\w)\1\1/' will find your triples, but watch
out for cases like '111111', i.e. two elided triples. Do you want that
to be two triples, or do you want it excluded as a sextuple? This
not-very-succinct code will find only triples, *not* quadruples,
quintuples, etc.
$a="baaab 111111 222 bbbb ccc 123444321 xzzz";
while($a=~m/(\d|\w)(?=\1\1)/g) {
print "match: $1$1$1"
if (pos($a)==1 || substr($a,pos($a)-2,1) ne $1) &&
(pos($a)==length($a)-1 || substr($a,pos($a)+2,1) ne $1);
}
There must be a better way ... ?
--
-- Tim Conrow tim@ipac.caltech.edu 626-395-8435
------------------------------
Date: Mon, 31 Jul 2000 23:29:38 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: How to recognize triplicates
Message-Id: <soc2v2e4dbm129@corp.supernews.com>
stillanewbie@db-networks.com wrote:
: How to recognize 3 times the same character or the same number?
:
: ie: 000 or 111 or AAA or ZZZ
:
: I have tried but: m/\D{3,}/ will match any 3 numbers in a row, not
: identical numbers
Actually, that will match any three non-numbers in a row; note that \D is
the opposite of \d.
To do what you want for the case of numbers, try /(\d)$1{2,}/ -- that is,
any digit, followed by that same digit 2 or more times in a row.
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Turning and turning in the widening gyre
| The falcon cannot hear the falconer." - Yeats, "The Second Coming"
------------------------------
Date: 31 Jul 2000 23:43:29 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: How to recognize triplicates
Message-Id: <8m52v0$5mcr3$13@ID-24002.news.cis.dfn.de>
hi,
Tim Conrow <tim@ipac.caltech.edu> wrote:
> stillanewbie@db-networks.com wrote:
>>
>> How to recognize 3 times the same character or the same number?
>>
>> ie: 000 or 111 or AAA or ZZZ
>>
>> I have tried but: m/\D{3,}/ will match any 3 numbers in a row, not
>> identical numbers
> As others have said, '/(\d|\w)\1\1/' will find your triples, but watch
^^^^^
(\d|\w) is the same as (\w) because \w contains \d.
> out for cases like '111111', i.e. two elided triples. Do you want that
> to be two triples, or do you want it excluded as a sextuple? This
> not-very-succinct code will find only triples, *not* quadruples,
> quintuples, etc.
> $a="baaab 111111 222 bbbb ccc 123444321 xzzz";
> while($a=~m/(\d|\w)(?=\1\1)/g) {
> print "match: $1$1$1"
> if (pos($a)==1 || substr($a,pos($a)-2,1) ne $1) &&
> (pos($a)==length($a)-1 || substr($a,pos($a)+2,1) ne $1);
> }
> There must be a better way ... ?
/(\w)\1{2,}/
regards,
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
please no answers via email unless followup is set to poster.
------------------------------
Date: 31 Jul 2000 23:46:55 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: How to recognize triplicates
Message-Id: <8m535f$5mcr3$14@ID-24002.news.cis.dfn.de>
hi,
Craig Berry <cberry@cinenet.net> wrote:
> stillanewbie@db-networks.com wrote:
> : How to recognize 3 times the same character or the same number?
> :
> : ie: 000 or 111 or AAA or ZZZ
> :
> : I have tried but: m/\D{3,}/ will match any 3 numbers in a row, not
> : identical numbers
> Actually, that will match any three non-numbers in a row; note that \D is
> the opposite of \d.
> To do what you want for the case of numbers, try /(\d)$1{2,}/ -- that is,
^^
> any digit, followed by that same digit 2 or more times in a row.
? you meant \1 instead of $1 I guess =)
regards,
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
please no answers via email unless followup is set to poster.
------------------------------
Date: Mon, 31 Jul 2000 23:52:55 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: How to recognize triplicates
Message-Id: <soc4anakdbm150@corp.supernews.com>
Craig Berry (cberry@cinenet.net) wrote:
: To do what you want for the case of numbers, try /(\d)$1{2,}/ -- that is,
: any digit, followed by that same digit 2 or more times in a row.
*forehead slap* Not $1, \1 -- sorry.
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Turning and turning in the widening gyre
| The falcon cannot hear the falconer." - Yeats, "The Second Coming"
------------------------------
Date: Mon, 31 Jul 2000 23:23:08 GMT
From: Howard <hxshxs@my-deja.com>
Subject: Open FILEs
Message-Id: <8m51om$mnm$1@nnrp1.deja.com>
this maybe too simple to ask:
I have a master script a.pl:
#a.pl
open(LOG, ">log.dat");
`perl b.pl`;
print LOG "something wrong in master script\n";
close LOG;
but in b.pl code, I also want to print something into LOG file. Can I use the
same filehandler LOG? even if I use another FILE HANDLER to open the same
file,
#b.pl
open(LOG2, ">log.dat");
print LOG2 "something wrong in b.pl\n";
close LOG2;
it seems that the message in b.pl won't print unless there is no "print
LOG...." in a.pl. I wonder if there is a way to have both messages printed?
Thanks. -Howard
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 01 Aug 2000 02:15:13 -0500
From: "Dietmar Staab" <dietmar.staab@t-online.de>
Subject: Re: Open FILEs
Message-Id: <8m54p9$tmq$17$1@news.t-online.com>
In article <8m51om$mnm$1@nnrp1.deja.com>, Howard <hxshxs@my-deja.com>
wrote:
> I have a master script a.pl:
>
> #a.pl
> open(LOG, ">log.dat");
> `perl b.pl`;
> print LOG "something wrong in master script\n"; close LOG;
>
> but in b.pl code, I also want to print something into LOG file. Can I
> use the same filehandler LOG? even if I use another FILE HANDLER to open
> the same file,
>
> #b.pl
> open(LOG2, ">log.dat"); print LOG2 "something wrong in b.pl\n"; close
> LOG2;
>
> it seems that the message in b.pl won't print unless there is no "print
> LOG...." in a.pl. I wonder if there is a way to have both messages
> printed?
Hi Howard, your output is buffered an not written immediatly to the file.
For the details have a look at perldoc -q buffer if you want to change
this behaviour.
When using the same logfile for different programs I suggest to lock the
file, if the order of the log entries matters.
Greetings, Dietmar
------------------------------
Date: 1 Aug 2000 00:31:12 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Open FILEs
Message-Id: <8m55og$5mcr3$15@ID-24002.news.cis.dfn.de>
hi,
Howard <hxshxs@my-deja.com> wrote:
> I have a master script a.pl:
> #a.pl
> open(LOG, ">log.dat");
> `perl b.pl`;
> print LOG "something wrong in master script\n";
> close LOG;
> but in b.pl code, I also want to print something into LOG file. Can I use the
> same filehandler LOG? even if I use another FILE HANDLER to open the same
> file,
into the same file?
then you should prefer writing
do 'b.pl';
rather than using backticks.
> #b.pl
> open(LOG2, ">log.dat");
> print LOG2 "something wrong in b.pl\n";
> close LOG2;
AFAIK then you can use the same variables in b.pl as in
a.pl.
to check if LOG is already opened you can test it with
dosomething() if fileno LOG;
regards,
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
please no answers via email unless followup is set to poster.
------------------------------
Date: 1 Aug 2000 00:32:55 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Parse::RecDescent with left-recursive grammar.
Message-Id: <8m55rn$qit$1@towncrier.cc.monash.edu.au>
abigail@foad.org (Abigail) writes:
>Omri Schwarz (ocschwar@mit.edu) wrote on MMDXXVI September MCMXCIII in
><URL:news:398525F0.ABCA33F9@mit.edu>:
>--
>-- Say, um, a frieend of mine, yeh, that's it, a friend of mine,
>-- writes a left-recursive grammar using RecDescent and sets 'nocheck',
>-- and runs it, what could happen?
>Did your friend try?
:-)
Well, <nocheck> is still vapourware (as I explained at TPC)
If you run a left-recursive grammar under <nocheck> you
will quickly get a "100 levels of recursion" warning, followed
eventually by an "out of memory" failure.
Left-recursion is forever! ;-)
Damian
------------------------------
Date: Tue, 01 Aug 2000 00:14:19 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Perl and MySQL
Message-Id: <3986160d.1450405@news.newsguy.com>
Mike Styne <mstyne@bownemgmt.com> wrote:
>I've been reading MySQL and mSQL by Yarger, R[****] & King.
Please don't use language like that on this newsgroup.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: 01 Aug 2000 00:07:06 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: Please unconfuse me.... if (<>)...
Message-Id: <aeeykl85.fsf@macforce.sumus.dk>
rocoto@my-deja.com writes:
> Given these constructs:
> while (<>) { ... }
> for (1;<>;1) { ... }
>
> Why doesn't this work:
> if (<>) { ... }
<> _only_ assigns to $_ automatically if it's all alone in a loop test. From
perlop on <>:
Ordinarily you must assign the returned value to a
variable, but there is one situation where an automatic
assignment happens. If and ONLY if the input symbol is
the only thing inside the conditional of a while or
for(;;) loop, the value is automatically assigned to the
variable $_. In these loop constructs, the assigned value
(whether assignment is automatic or explicit) is then
tested to see if it is defined.
--
Jakob Schmidt
http://aut.dk/orqwood
etc.
------------------------------
Date: Mon, 31 Jul 2000 22:35:48 GMT
From: Doug Harrison <dsh@mvps.org>
Subject: Possible regex regression in 5.6.0
Message-Id: <1evbosgj5q2jb1n3rrbhk5ttl43dm58tdc@4ax.com>
Consider the following program:
{
$x = "1\nabcabcabcabc\n";
print "match 1\n" if $x =~ /^.{9}abc.*\n/m;
}
{
$x = "12\nabcabcabcabc\n";
print "match 2\n" if $x =~ /^.{9}abc.*\n/m;
}
{
# Fails in Perl 5.6.0
$x = "123\nabcabcabcabc\n";
print "match 3\n" if $x =~ /^.{9}abc.*\n/m;
}
{
# Replacing penultimate 'c' with 'X' fixes it
$x = "123\nabcabcabXabc\n";
print "match 4\n" if $x =~ /^.{9}abc.*\n/m;
}
{
# Replacing .* with .? fixes it
$x = "123\nabcabcabcabc\n";
print "match 5\n" if $x =~ /^.{9}abc.?\n/m;
}
Under 5.005_03, the output is:
match 1
match 2
match 3
match 4
match 5
Under 5.6.0 (ActivePerl build 616), the output is:
match 1
match 2
match 4
match 5
I don't see why 5.6.0 failed on match 3. Any ideas?
--
Doug Harrison
Eluent Software, L.L.C.
http://www.eluent.com
------------------------------
Date: Mon, 31 Jul 2000 16:20:44 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: printf %e exponent digits
Message-Id: <MPG.13efa99fdac9986d98ac12@nntp.hpl.hp.com>
In article <3985EE26.AF8B27B9@gsfc.nasa.gov> on Mon, 31 Jul 2000
17:22:46 -0400, Jonathan Kuhn <jonathan.kuhn@gsfc.nasa.gov> says...
> Here is what I get:
>
> perl -we 'printf("%10.2e\n",123.456e10)'
> 1.23e+012
>
> I ended up running the strings through s/([+-])\d(\d\d)/$1$2/g
That may work for your data, but the range of exponents with standard
IEEE representation is greater than -99 to +99. Checking for an
explicit 0 instead of the digit you discard blindly would be safer.
> I will e-mail a description to activestate.
Why? This doesn't seem like a bug. They rely on the underlying C
library to generate the output, and the number of digits isn't specified
except to be at least two digits. If you are concerned about
portability in this area, you should deal with it yourself.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 31 Jul 2000 18:12:57 EDT
From: abigail@foad.org (Abigail)
Subject: Re: question about a Regular Expression
Message-Id: <slrn8obuet.vcg.abigail@alexandra.foad.org>
Philip Taylor (phil.taylor@bigfoot.com) wrote on MMDXXVI September
MCMXCIII in <URL:news:8m4o2e$krs$1@news6.svr.pol.co.uk>:
-: I have constructed the following regular expression to validate scores:-
-:
-: /^\s*[0-9]{1,2}\s*\-\s*[0-9]{1,2}\s*$/
-:
-: it's purpose is to validate scores eg "13-2", but I also want to allow for
-: spaces being entered within the score eg " 12 - 2".
-:
-: It seems a bit long winded and I would be grateful for suggestions on how
-: it's form/performance may be improved.
use Parse::RecDescent;
print defined Parse::RecDescent -> new ('score: /\d\d?/ /-/ /\d\d?/ /$/')
-> score (' 12 - 2') ? "Yes\n" : "No\n";
Abigail
--
map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;
print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";
------------------------------
Date: 31 Jul 2000 22:52:13 GMT
From: "Steve Pass" <stevep@oz.net>
Subject: question about the insert sql command.
Message-Id: <8m4vut$jhb$0@216.39.145.147>
I'm trying to create a script that gets a hostname from a database, telnet's
to the device and gets some information and puts it back into the database.
My problem is putting the returned information back into the same table as
the requested device. The requested device is set as the primary key. I'm
using the INSERT command, but it appears that I cannot write to the table,
however if I create a new table the command works. Is there a way to write
this information to the same table? Here is an example of the code I'm using
for the Insert command. Quick general info. This is on a Winnt, going to an
access database, the database is called Hosts and the table is called
tblHostID, which contains two fields: Hostname and Version. TIA!
(I edited quite a bit out to get to the jist of it.)
my($db) = new Win32::ODBC('Hosts');
$db->Sql("SELECT Hostname FROM tblHostID");
while ($db->FetchRow()) {
my(%data) = $db->DataHash();
my($prompt);
use Net::Telnet;
$t->open(Host => $data{'Hostname'});
$t->print("sh ver");
@info = $t->getlines;
my($stat) = new Win32::ODBC ('Hosts');
$sql = "INSERT INTO tblHostID (Version) VALUES ('$info[1]');";
$stat->Sql($sql);
------------------------------
Date: Mon, 31 Jul 2000 23:48:11 +0200
From: ch-kaufhold@gmx.de (Christian Kaufhold)
Subject: Re: Quotes in regex?
Message-Id: <8m4t1c$hgs$3@f40-3.zfn.uni-bremen.de>
Colin Keith <ckeith@clara.net> wrote:
> In article <8m2epg$dv0$2@f40-3.zfn.uni-bremen.de>, ch-kaufhold@gmx.de (Christian Kaufhold) wrote:
[...]
>>Why does it allow for "2" being unquoted?
> I was always under the impression that (in HTML3.2, the last standard before
> HTML4 in which the <FONT> tag was depreciated anyway) numerical values could
> be unquoted. To make sure I wasn't about to have to blush more I checked
Of course, but we were not parsing HTML here, only something much more
specific. I was just wondering why the wildcard didn't allow it.
>>It has to do more case-insensitive comparisons.
>
> They both have /i ... ?
I thought it would make more difference because for the second it mat-
tered only for one letter, but it seems that the additional time is
nearly constant.
Benchmark: timing 100000 iterations of noi text, noi wildcard, text, wildcard...
noi text: 3 wallclock secs ( 4.01 usr + 0.00 sys = 4.01 CPU)
noi wildcard: 7 wallclock secs ( 6.74 usr + 0.00 sys = 6.74 CPU)
text: 4 wallclock secs ( 5.35 usr + 0.00 sys = 5.35 CPU)
wildcard: 7 wallclock secs ( 7.92 usr + 0.00 sys = 7.92 CPU)
(Using your test and changing the case of "arial" in one place).
Christian
--
END {print}
BEGIN{$_="70A5A3A4288D9C9DA49691A2287891A29A286E8D8F9991A2\n"}
END {$_=join!!'',(map{$_=$_{$_};map{chr oct hex}/../g}keys%_),keys%_}
BEGIN{%_=reverse split '\b'}
------------------------------
Date: Mon, 31 Jul 2000 18:32:57 -0400
From: Ron Grabowski <ronnie@catlover.com>
Subject: Re: Rounding numbers in Perl
Message-Id: <3985FE99.437FA058@catlover.com>
> $filesize = stat($file_name)[7] / 1024;
>
> I want to round filesize to one digit after the point and I am not sure
> how to do it. I know print command allows to format the output string,
$filesize = sprintf "%.1f", (-s $filename) / 1024;
------------------------------
Date: Mon, 31 Jul 2000 16:00:53 -0700
From: RS@ <rschram@reed.edu>
Subject: Re: Rounding numbers in Perl
Message-Id: <0a671b5d.ae7591dd@usw-ex0105-036.remarq.com>
As per the FAQ (http://cs.georgefox.edu/~bbrewer/division.html),
a positive real "a" can have a positive integer quotient "q" iff
R = x-qn and n (the divisor) is an integer.
Hence the statement "'a' has a highest integer divisor" should
read "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."
(Cit:
"http://www.perl.com/pub/doc/manual/html/pod/perlop.html#Multipli
cative_Operators" -- But who the hell wants to say all that?)
Or, a % b = a - xb, where xb < a.
So, I misspoke, but you're still silly.
Having said that, please see this CGI gem
(http://www.cookwood.com/perl/examples/scalars/modulus.html)
If R(a/b) < 0, a % b = 0. Shucks.
Better to use subtraction
my $x = $some_positive_real;
my $n = 1;
while (my $n < $positive_infinity) {
my $d = $x - $n;
if (1 < $d < 0) { $foundround = $n;
if ($d > 0.5) { $foundround++; last; }
}
else ++$n;
}
-----------------------------------------------------------
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
------------------------------
Date: Mon, 31 Jul 2000 16:30:29 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Rounding numbers in Perl
Message-Id: <MPG.13efabf06e552b4198ac13@nntp.hpl.hp.com>
In article <8m4qga$85f$1@provolone.cs.utexas.edu> on 31 Jul 2000
16:19:06 -0500, Logan Shaw <logan@cs.utexas.edu> says...
> In article <0d87be38.608e4ce0@usw-ex0102-014.remarq.com>,
> RS@ <rschram@reed.edu> wrote:
...
> $number = int ($number + 0.5);
...
> return $precision * int ( ($number / $precision) + 0.5 );
...
> sub round { $_[1]*int($_[0]/$_[1]+.5); }
Numbers can be negative also. Either test the sign and add/subtract 0.5
as appropriate, or do it the easy way with sprintf.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 31 Jul 2000 19:23:02 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Rounding numbers in Perl
Message-Id: <8m5596$8kk$1@provolone.cs.utexas.edu>
In article <MPG.13efabf06e552b4198ac13@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>Numbers can be negative also. Either test the sign and add/subtract 0.5
>as appropriate, or do it the easy way with sprintf.
The numbers in the original example can't be negative, because they're
file sizes. But yes, if you need this to work for negative numbers, so
more work is required.
- Logan
------------------------------
Date: 31 Jul 2000 20:00:27 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Rounding numbers in Perl
Message-Id: <8m57fb$8sg$1@provolone.cs.utexas.edu>
In article <0a671b5d.ae7591dd@usw-ex0105-036.remarq.com>,
RS@ <rschram@reed.edu> wrote:
>As per the FAQ (http://cs.georgefox.edu/~bbrewer/division.html),
>a positive real "a" can have a positive integer quotient "q" iff
>R = x-qn and n (the divisor) is an integer.
This statement isn't very helpful since you haven't defined half of the
variables in the equation you give. What are "R" and "x"? Also, you
haven't mentioned how that equation relates to your positive real "a".
>Hence the statement "'a' has a highest integer divisor" should
>read "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."
Notice that it says -integer- operands.
>Or, a % b = a - xb, where xb < a.
And where "a" and "b" are integers.
>Having said that, please see this CGI gem
>(http://www.cookwood.com/perl/examples/scalars/modulus.html)
I'm not sure I would call it a gem.
I entered 5656 as the number and 56.8 as the divisor. It says "The
remainder of 5656 divided by 56.8 is 0". That doesn't make much sense
to me. 5656 / 56.8 is about equal to 99.57746478873239436619, which
means that the remainder should be 5656 - 99 * 56.8, or 32.8.
So it should say something like "Getting the remainder of the division
of two integers" rather than "Getting the remainder of the division of
two numbers."
>Better to use subtraction
Why is it better to use subtraction? The machine provides operators
that will help you achieve your result much more easily and directly.
The most important one is the function int(). With it, you can
find the integer part of a number. Even better is POSIX::floor().
With these, it's very easy to find the largest integer
that is not greater than the given real number, even if
the real number is negative. Once you have that ability,
rounding is easy -- just find the largest integer that is
not greater than the given real number plus 0.5.
>my $x = $some_positive_real;
>my $n = 1;
>while (my $n < $positive_infinity) {
>
> my $d = $x - $n;
> if (1 < $d < 0) { $foundround = $n;
> if ($d > 0.5) { $foundround++; last; }
> }
> else ++$n;
>
>}
Why are comparing a known-to-be-finite number to positive infinity?
(And why are you re-declaring it as you do so?)
Also, do you have any idea how long this will take if the supplied
positive real number is very large? It will never terminate. Why?
Because real numbers in perl are represented by floating point numbers
with a finite precision. Eventually, you will reach a point where your
floating point number is so large that its representation's precision
will be worse than 1. At that point, adding 1 will have no effect.
Here's an example:
$x = 10;
$y = $x + 1;
if ($y == $x)
{ print "They are equal.\n"; }
else
{ print "They are not equal.\n"; }
This will print "They are not equal.". Here's another example:
$x = 10e30;
$y = $x + 1;
if ($y == $x)
{ print "They are equal.\n"; }
else
{ print "They are not equal.\n"; }
This will print "They are equal.".
Thus, for sufficiently large numbers, your loop will eventually reach a
point where "++$n" doesn't do anything, and the loop will never
terminate.
So, it may be more fun to think of it with subtraction, but it is not
better to use subtraction in a real perl program.
- Logan
------------------------------
Date: Tue, 01 Aug 2000 00:53:26 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Running other programs in background
Message-Id: <ce6cosofej1cpfd292qp7quer3jia06f78@4ax.com>
ericr@yankthechain.com wrote:
>Oy, now how do I close the application?
Are you using ActiveState Perl 5.005 or Perl 5.5? Because you really
ought to look at the module Win32::Process, but that currently only
exists precompiled for Perl5.005, and these are not binary compatible.
The DLL's made for one version will crash the other.
The modules for 5.005 can be found at
<http://www.activestate.com/PPMPackages/5.005/zips/>, and for 5.6 at
<http://www.activestate.com/PPMPackages/5.6/zips/>.
To make a long story short: this module has a "Kill" method.
As for doing it without that module... no, I can't say I can find
anything. In VB, I'd say: activeate the windows, and then do Sendkeys
with the key combination Alt-F4. But in Perl... ?
--
Bart.
------------------------------
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 V9 Issue 3864
**************************************