[12821] in Perl-Users-Digest
Perl-Users Digest, Issue: 231 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 22 23:07:18 1999
Date: Thu, 22 Jul 1999 20:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 22 Jul 1999 Volume: 9 Number: 231
Today's topics:
Re: a CGI problem (Martien Verbruggen)
Re: Can't modify array deref in addition (Abigail)
Re: compile failed (Anno Siegel)
Re: Creating more filedescriptors on the fly <rick.delaney@home.com>
Re: doing an ls in PERL (globbing) <cassell@mail.cor.epa.gov>
Re: doing an ls in PERL (globbing) (Anno Siegel)
Re: Executing system commands (Abigail)
Re: exporting database table to text <bwalton@rochester.rr.com>
Re: Fun with Net:NNTP (Martien Verbruggen)
Re: getting the decimal portion of a floating point num (Steven Smolinski)
Re: getting the decimal portion of a floating point num (Anno Siegel)
Re: getting the decimal portion of a floating point num (Larry Rosler)
Re: Help please - running Perl/CGI scripts on MS NT Per <cassell@mail.cor.epa.gov>
Re: Help! (Abigail)
Re: How to give Passwords on STDIN (Martien Verbruggen)
Re: How to guarantee a socket connection? (Anno Siegel)
Re: need to redirect STDOUT and STDERR <rick.delaney@home.com>
null byte in open's filename? <jbc@shell2.la.best.com>
Re: null byte in open's filename? <tchrist@mox.perl.com>
Re: Parse::RecDescent (Damian Conway)
Re: Perl Math Calculation vs. FORTRAN Calculations <kperrier@blkbox.com>
Re: Perl Math Calculation vs. FORTRAN Calculations (Ilya Zakharevich)
Re: perl vs. FORTRAN Caculations <cassell@mail.cor.epa.gov>
POSIX module <trcull@my-deja.com>
Re: POSIX module <tchrist@mox.perl.com>
Re: POSIX module (Abigail)
Re: Prime Factorization (Ilya Zakharevich)
Re: Problem compiling 'write' <palincss@his.com>
Re: problem with hash of arrays (Ronald J Kimball)
Question about troubleshooting mirror.pl <gnielson@charlotte.infi.net>
Re: Retrieving NT Services <cassell@mail.cor.epa.gov>
Re: searching man pages, perldoc's, FAQ's, README's, HO <cassell@mail.cor.epa.gov>
Re: setuid and opening a file for writing (Ronald J Kimball)
Re: TextArea fields (Anno Siegel)
Re: waitpid crashes perl (Charles DeRykus)
Re: What is the best way to write data to a com port un <cassell@mail.cor.epa.gov>
Re: What is the best way to write data to a com port un <ron_savage@non-hp-australia-om5.om.hp.com>
Win32::EventLog <ppopour@infoave.net>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 23 Jul 1999 02:15:35 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: a CGI problem
Message-Id: <bfQl3.121$d37.7504@nsw.nnrp.telstra.net>
In article <7mdd9j$o9e$1@gemini.ntu.edu.tw>,
venice@video.ee.ntu.edu.tw (Yang Zhong-Lan) writes:
> <input type="text" name="aaa" value="dontchange">
This is not even a CGI problem, but a HTML problem. You should read
some stuff on that. perl cannot help you here, neither can CGI.
Ask in a group that talks about CGI, HTML, or something like that. If
I tell you you need to ask about hidden input stuff, maybe you can in
the meantime try to find the answer yourself somewhere.
For future reference, ask perl questions on a perl newsgroup, cgi
questions on a cgi newsgroup, and html questions on a html newsgroup.
Martien
--
Martien Verbruggen |
Interactive Media Division | That's funny, that plane's dustin'
Commercial Dynamics Pty. Ltd. | crops where there ain't no crops.
NSW, Australia |
------------------------------
Date: 22 Jul 1999 21:48:29 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Can't modify array deref in addition
Message-Id: <slrn7pfluo.1a1.abigail@alexandra.delanet.com>
Tomas Karlsson (tomas.karlsson@andover.net) wrote on MMCLI September
MCMXCIII in <URL:news:37973D2E.DEB2FBEF@andover.net>:
// Hi,
//
// A short question about references. I would like to make changes to 3
// elements at the same time, but Perl doesn't like my code. I have:
//
// @{$totals{$dateref}} += @{$table{$site}{$dateref}} foreach my
// $dateref (keys %{$table{$site}});
//
// and I get the error message: "Can't modify array deref in addition". Ok
// so that clearly doesn't work. The only solution that I came up with is
//
// $totals{$dateref}->[0] += $table{$site}{$dateref}->[0];
// $totals{$dateref}->[1] += $table{$site}{$dateref}->[1];
// $totals{$dateref}->[2] += $table{$site}{$dateref}->[2];
//
// It works, but with more elements it will become cumbersome. Could anyone
// show me a neater way to solve my problem? Thanks in advance!
my ($dateref, $siteref);
while (($dateref, $siteref) = each %{$table {$site}}) {
my $i = 0;
foreach my $totaldateref (@{$totals {$dateref}}) {
$totaldateref += $siteref -> [$i ++];
}
}
Abigail
--
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
-----------== 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: 23 Jul 1999 02:00:16 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: compile failed
Message-Id: <7n8ibg$vum$1@lublin.zrz.tu-berlin.de>
doug edmunds <edmundsXXX@pacifier.com> wrote in comp.lang.perl.misc:
[...]
>There is a newer DB version from Berkeley.
>Check out www.sleepycat.com for info about the updated DB. They
>say they have a new perl .pm for it (which changed the name),
>but I don't know if the standard perl installation will build
>it.
When you build the new Berkeley DB v 2.7.5, a corresponding file
db.h is created. If this is installed wherever Config looks for
db.h (/usr/include, normally), the perl build will be for the
new version of Berkeley DB. Of course, to run it, libdb.so must
be installed too.
Anno
------------------------------
Date: Fri, 23 Jul 1999 00:47:39 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Creating more filedescriptors on the fly
Message-Id: <3797BB7F.7322AF67@home.com>
[posted & mailed]
Morten Hanshaugen wrote:
>
> Anybody knowing how to do create more filedescriptors dynamically?
use Symbol;
You might also want to look into IO::Socket or the other IO modules.
> package Connection;
> my(NS);
That certainly won't work, but you did say pseudo-code.
> my $fd;
>
> sub new
> {
> my $type = shift;
> my $sock = shift;
> $fd = shift;
my $fd = gensym;
This will give you a different typeglob reference for each instance of
your class. If you want to pass it as an argument, then do this before
creating your object.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Thu, 22 Jul 1999 17:18:47 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: doing an ls in PERL (globbing)
Message-Id: <3797B4E7.42936620@mail.cor.epa.gov>
Tom Briles wrote:
>
> Bruno Pagis wrote:
> >
> > If you don't mind using existing code
>
> Personally, I only use code that doesn't exist. My programs don't do
> much, but (knock on wood) I've *never* had a bug.
You only use code that doesn't exist? And you've never had a
bug? Are you really Edward Dijkstra? :-)
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 23 Jul 1999 00:48:39 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: doing an ls in PERL (globbing)
Message-Id: <7n8e57$vpp$1@lublin.zrz.tu-berlin.de>
David Cassell <cassell@mail.cor.epa.gov> wrote in comp.lang.perl.misc:
>Tom Briles wrote:
>>
>> Bruno Pagis wrote:
>> >
>> > If you don't mind using existing code
>>
>> Personally, I only use code that doesn't exist. My programs don't do
>> much, but (knock on wood) I've *never* had a bug.
>
>You only use code that doesn't exist? And you've never had a
>bug? Are you really Edward Dijkstra? :-)
Two axioms of programming:
1) Every program has a bug.
2) Every program can be made one statement shorter.
Corollary: Every program can be reduced to a single statement that
doesn't work.
But you have heard that before...
Anno
------------------------------
Date: 22 Jul 1999 21:51:56 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Executing system commands
Message-Id: <slrn7pfm57.1a1.abigail@alexandra.delanet.com>
Jean-Marc Beaudoin (beaudoin.jean-marc@-NOSPAM-hydro.qc.ca) wrote on
MMCLI September MCMXCIII in <URL:news:cnFl3.9129$8v6.586329@carnaval.risq.qc.ca>:
[]
[] How can I execute an O/S command with perl?
There are at least 4 different ways to do that in Perl.
There are all documented.
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
-----------== 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, 22 Jul 1999 22:41:41 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: exporting database table to text
Message-Id: <3797D665.8F551528@rochester.rr.com>
Sriram Narayanan wrote:
> i would like to export a ms access table to text with a header and
> footer. ideally, the header would have the name of the table and date
> and the footer would have the number of records in the table..is perl
> the way to go? (i'm a newbie) if so, where do i start?
> a billion thanks in advance..
Wow. For that many thanks, here is a bit of a program that should get you
started on one way to do it:
# ODBC test program
# Seting up an ODBC database
#a) Click Settings/ControlPanel
#b) Click 32-Bit ODBC
#c) Select "System DSN" tab
#d) Click Add, select "Microsoft Access Driver", click Finish
#e) Enter the following properties
# Data Source Name: test_dsn (This is the most important field)
# Description: Anything
#f) Click on Create... and choose a filename, eg. c:\database\test.mdb
#g) Next time Click on Select ... and choose a filename, eg.
c:\database\test.mdb
use Win32::ODBC;
&insertData;
&getData;
exit(0);
sub insertData {
$dsn = "test_dsn";
$db = new Win32::ODBC($dsn);
die "ERROR: Failed to open database\n" if(!$db);
$sql = "CREATE TABLE test_table (";
$sql .= "id char(02), ";
$sql .= "name char(04), ";
$sql .= "city char(03) )";
$db->Sql($sql);
($ErrNum, $ErrText, $ErrConn) = $db->Error();
$sql = "DELETE FROM test_table";
$db->Sql($sql);
$sql = "INSERT INTO test_table (id, name, city) VALUES ('01', 'Jack',
'NY')";
$db->Sql($sql);
$sql = "INSERT INTO test_table (id, name, city) VALUES ('02', 'John',
'Lon')";
$db->Sql($sql);
$sql = "INSERT INTO test_table (id, name, city) VALUES ('03', 'Mike',
'HK')";
$db->Sql($sql);
$sql = "INSERT INTO test_table (id, name, city) VALUES ('04', 'Carl',
'LA')";
$db->Sql($sql);
}
sub getData {
$sql = "SELECT * from test_table order by id";
$db->Sql($sql);
while ($db->FetchRow()) {
($id, $name, $city) = $db->Data("id", "name", "city");
print $id, " - ", $name, " - ", $city, "\n";
}
$db->Close();
}
(courtesy of the perl2exe folks)
To get the date, see the "localtime" function (docs in perlfunc). See the
Win32::ODBC docs or http://www.roth.net/odbc for how to retrieve table
names if you think you need to do that.
------------------------------
Date: Fri, 23 Jul 1999 02:47:52 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Fun with Net:NNTP
Message-Id: <sJQl3.129$d37.7504@nsw.nnrp.telstra.net>
In article <7n62ev$nrk$1@216.39.141.200>,
tgy@chocobo.org (Neko) writes:
>>my $newsptr = Net::NNTP->new('news.mixcom.com');
>
> You fail to check if this succeeds. You may want to include $newptr->message
> in your error message.
But.. if this fails, it most likely returns undef, which means that
$newsptr is not going to have a 'message' sub. :) Actually looking at
the code shows many places where new will return undef. Checking for
errors is good. Sometimes, however, you can't really get an error
message from the underlying constructors.
Unless there's some hidden magic in leaving the s out of newsptr? :)
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: 23 Jul 1999 00:44:23 GMT
From: stevens@frisco.gulch.com (Steven Smolinski)
Subject: Re: getting the decimal portion of a floating point number
Message-Id: <slrn7pfah5.g0.stevens@frisco.gulch.com>
On Thu, 22 Jul 1999 11:05:41 -0700, Larry Rosler <lr@hpl.hp.com> wrote:
=perl -e 'print 12345.6789; printf " %.14f\n", 12345.6789'
=
=12345.6789 12345.67890000000100
As an amateur, I would love for someone to explain why a floating-point
representation of 12345.6789 would *add* data that wasn't explicitly
assigned to it. It certainly isn't what I would have expected.
Any references to texts which may cover this are welcome as well.
Steve
------------------------------
Date: 23 Jul 1999 01:30:22 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: getting the decimal portion of a floating point number
Message-Id: <7n8gje$vsc$1@lublin.zrz.tu-berlin.de>
Steven Smolinski <stevens@frisco.gulch.com> wrote in comp.lang.perl.misc:
>On Thu, 22 Jul 1999 11:05:41 -0700, Larry Rosler <lr@hpl.hp.com> wrote:
>
>=perl -e 'print 12345.6789; printf " %.14f\n", 12345.6789'
>=
>=12345.6789 12345.67890000000100
>
>As an amateur, I would love for someone to explain why a floating-point
>representation of 12345.6789 would *add* data that wasn't explicitly
>assigned to it. It certainly isn't what I would have expected.
It doesn't add data, but it is forced to use an approximation in
certain cases.
A number, even if it is rational (i.e. the quotient of two integers)
can not always be represented with a final number of digits. It
happens in the decimal system too: 1/3 = 0.3333... can't be represented
exactly as a decimal fraction while 1/2 = 0.5 can. Exactly which
rationals can be represented depends on the base of the number system.
In the ternary (base 3) system we luck out on 1/3 = 0.1, but 1/2 is
0.1111....
So, because most computers these days use the binary system (base 2),
some numbers that have an exact decimal representation like 12345.6789
above, can't be converted to an exact representation inside the computer.
Instead, the closest number that *has* a representation in so many bits
is used. When this approximation is again converted to decimal output,
we see a small difference. This doesn't happen with, for instance, 0.5,
which can be written in finitely many digits in decimal *and* in binary
(it's 0.1 in binary).
Of course there are are systems that do a better job with rational
numbers; Perl's Math::BigFloat is an example. These systems will
always try do work with an exact representation of the input or whatever
was calculated from it, but they may run out of memory doing so.
Anno
------------------------------
Date: Thu, 22 Jul 1999 18:40:14 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: getting the decimal portion of a floating point number
Message-Id: <MPG.120167daa495e161989d24@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <slrn7pfah5.g0.stevens@frisco.gulch.com> on 23 Jul 1999
00:44:23 GMT, Steven Smolinski <stevens@frisco.gulch.com> says...
> On Thu, 22 Jul 1999 11:05:41 -0700, Larry Rosler <lr@hpl.hp.com> wrote:
>
> =perl -e 'print 12345.6789; printf " %.14f\n", 12345.6789'
> =
> =12345.6789 12345.67890000000100
>
> As an amateur, I would love for someone to explain why a floating-point
> representation of 12345.6789 would *add* data that wasn't explicitly
> assigned to it. It certainly isn't what I would have expected.
Nothing is added. That is the closest approximation to the internal
*binary* representation of the number. Just because it is expressible
as an apparently precise decimal fraction does not mean it has an exact
binary representation. For example, 0.1 has no exact binary
representation. This is analogous to the situation where the rational
fraction 1/3 has no exact decimal representation; 0.33333.... is an
approximation, no matter how many digits you use.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 22 Jul 1999 17:59:26 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Help please - running Perl/CGI scripts on MS NT Personal Web Server.
Message-Id: <3797BE6E.893FBD8F@mail.cor.epa.gov>
Nico Zigouras wrote:
>
> Hi:
>
> I know this is also a web server question, but does anyone know if you
> can run CGI sscripts on MS Personal Web Server for NT? I couldn't find
> any mention of CGI/Perl in the docs, just Microsoft pushing ASP.
Yes, you can. In fact, in the ActivePerl FAQ which comes with
your win32 install of Perl from ActiveState [there's even an
HTML version of this on your Start Menu], there are instructions
for getting PWS to admit that perl programs are executables too.
> Thanks.
You're welcome.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 22 Jul 1999 21:55:50 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Help!
Message-Id: <slrn7pfmcg.1a1.abigail@alexandra.delanet.com>
karsten_beijer@my-deja.com (karsten_beijer@my-deja.com) wrote on MMCLI
September MCMXCIII in <URL:news:7n77fg$rmt$1@nnrp1.deja.com>:
%% I am using the perl script from my provider, I use an guestbook en form.
%%
%% Now Í want the same background (my background) on every page.
%%
%% Í maem: if there is an error (because you didn't fill in your name)
%% then come an white page, but I want mij page background
And what is your Perl question? How to do backgrounds in Web pages
is best found in the CSS specification. CSS ain't Perl.
If you have Perl specific problems with the script, you could ask here,
but since it's your providers script, you ought to get much better help
from your provider.
%% You can e-mail me at karsten@reproshop.nl
Oh, really? That's not what your headers say.
Abigail
--
perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'
-----------== 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: Fri, 23 Jul 1999 02:42:39 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How to give Passwords on STDIN
Message-Id: <zEQl3.126$d37.7504@nsw.nnrp.telstra.net>
In article <3795fff0.0@news.arcor-ip.de>,
"osman durrani" <osman@focomedia.de> writes:
> actually i wanted to know how can i get a password but not have the
> passwaord visible on the STDIN.
Then, next time you have a question, ask a bit more precisely what you
want. Be precise, and increase the chance of actually getting your
question across in such a way that it cannot be misunderstood. Be
vague, and prepare for amny answers which are not related at all to
what you had in mind.
We do not have ESP, apart from a few people here, who do.
> This way you see the actuall password ,so it is not very good if you want to
> keep your password secrete from prying eyes.
Hmmm. I don't believe that anybody, ever has asked that question
before. In fact it sounds so obscure that it must be the absolutely
first time that it's ask. It would not ever be in the frequently asked
questions list... Would it?
Let's just check. Just to make sure. Just so that we don't go off and
post a FAQ to the newsgroup and piss off half the people there.
# perldoc -q password
=head1 Found in /usr/local/lib/perl5/5.00502/pod/perlfaq8.pod
=head2 How do I ask the user for a password?
Whoops. it does turn out to be a FAQ. Am I ever glad that I didn't
post this question, but instead decided to consult the documentation
and the FAQ.
Phew.
Martien
--
Martien Verbruggen |
Interactive Media Division | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd. | negative.
NSW, Australia |
------------------------------
Date: 23 Jul 1999 00:44:29 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to guarantee a socket connection?
Message-Id: <7n8dtd$voh$1@lublin.zrz.tu-berlin.de>
<tosh2@my-deja.com> wrote in comp.lang.perl.misc:
>Hi, I have a program that runs for 8 hours a day. During that 8 hours
>the program makes socket connections. Sometimes it is unable to do so,
>but I need the data from the connection, which will be made eventually,
>so how do I keep trying to make the connection until it is successful?
>
>I've tried:
>
>while(!($remote = IO::Socket::INET->new(Proto => "tcp", PeerAddr
> => $host, PeerPort
> => "http(80)")))
>which doesn't seem to be yielding the results I am after.
No, it doesn't even compile, and the formatting is pretty weird. Please,
unless your question is "Why doesn't this compile", post code that can
be tested.
Otherwise I don't see what's basically wrong with your approach. In the
(currently missing) loop body you may want to test $! to see if it's
at all reasonable to retry. Also, you should sleep() a few minutes
each time around.
Alternatively, you could use Net::Ping to see if the remote host is up.
Of course, even if it's up that doesn't mean it will accept connections
on port 80.
Anno
------------------------------
Date: Fri, 23 Jul 1999 00:25:05 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: need to redirect STDOUT and STDERR
Message-Id: <3797B635.55BEDB79@home.com>
[posted & mailed]
Jonathan Kart wrote:
>
> is there any way on WinNT to redirect STDOUT and/or STDERR to a log file?
Look up the open function in the manual.
perldoc -f open
open(STDOUT, ">foo.out") || die "Can't redirect stdout: $!";
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: 23 Jul 1999 00:09:50 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: null byte in open's filename?
Message-Id: <3797b2ce$0$204@nntp1.ba.best.com>
In recipe 20.9 (Creating HTML Templates) from the Perl Cookbook there's
the following line:
open(F, "< $filename\0") || return;
This is in a subroutine with a localized filehandle, though I don't
know if that's relevant to my question, which is, why is the null byte
there at the end of $filename? What is a null byte, anyway? I've seen it
referred to in passing, somewhere or other in the Camel book (I think),
but can't find the reference now.
Can I just eliminate it from the example and expect it to work more or
less the same for most purposes? I'm loathe to alter an incantation
that I don't understand, but neither do I want to build a runway and
control tower out of vines and bamboo in a futile effort to bring the
cargo back.
Any enlightenment will be appreciated. Thanks.
--
John Callender
jbc@west.net
http://www.west.net/~jbc/
------------------------------
Date: 22 Jul 1999 18:26:05 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: null byte in open's filename?
Message-Id: <3797b69d@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
John Callender <jbc@shell2.la.best.com> writes:
:In recipe 20.9 (Creating HTML Templates) from the Perl Cookbook there's
:the following line:
:
:open(F, "< $filename\0") || return;
:
:This is in a subroutine with a localized filehandle, though I don't
:know if that's relevant to my question, which is, why is the null byte
:there at the end of $filename? What is a null byte, anyway?
Try the perlopentut manpage, if you have it.
--tom
--
MSDOS isn't dead. It just smells like it.
------------------------------
Date: 23 Jul 1999 01:58:26 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Parse::RecDescent
Message-Id: <7n8i82$h91$1@towncrier.cc.monash.edu.au>
Andrew D Matuszak <adm4@acsu.buffalo.edu> writes:
>Wondering if someone could give me a good hint on the following. Have
>data file that needs to be read in as a hash using the
>Parse::RecDescent mod. Here is what I have done, but I would like any
>suggestions on how to do it more efficently.
Don't use RecDescent :-)
Seriously, your grammar is so simple it could be implemented far more efficiently
in a simple loop:
--------------------------------------------------------------------------------
# WARNING - NOT TESTED
# EXPOSITION ONLY
open (FH, "/root/ISC/t/dhcpd.leases") or die "Can't open File: $!\n";
my $ip;
my %leasehash;
my $keywitharg = qr/ starts
| ends
| hardware
| dns \s forward
| dns \s reverse
| uid
| client-hostname
/x;
my $keynoarg = qr/ abandoned
| dynamic-bootp
/x;
while (<FH>)
{
/lease \s+ (\d+\.\d+\.\d+\.\d+) \s+ {/ and do { $ip = $1; 1}
or /($keywitharg) \s+ (.*) \s+ ;/x and do { $leasehash{$ip}->{$1} = $2; 1}
or /abandoned/ and do { $leasehash{$ip}->{$1} = 1; 1}
or /}/
or /.*/ and do { print "$item[1]\n"; 1}
}
--------------------------------------------------------------------------------
If your set on using RecDescent, I'd be inclined to write it like so
(note the similarities to the above code)
--------------------------------------------------------------------------------
# WARNING - NOT TESTED
# EXPOSITION ONLY
use Parse::RecDescent;
open (FH, "/root/ISC/t/dhcpd.leases") or die "Can't open File: $!\n";
my $ip;
my %leasehash;
sub Parse::RecDescent
$::RD_AUTOSTUB = q{ $::leasehash{$::ip}->{'start'} = $1; }
$grammar = <<'EOGRAMMAR';
startrule:
"lease" /\d+\.\d+\.\d+\.\d+/ /\{/
{ $::ip = $item[2];}
| keyword text /;/ { $::leasehash{$::ip}->{$item[1]} = $item[2] }
| flag { $::leasehash{$::ip}->{$item[1]} = 1 }
| /\}/
| /.*/ { print "$item[1]\n" }
keyword: / starts
| ends
| hardware
| dns \s forward
| dns \s reverse
| uid
| client-hostname
/x
flag: / abandoned
| dynamic-bootp
/x;
text: /.*(?=;)/
EOGRAMMAR
$parser = new Parse::RecDescent ($grammar) or die "Bad grammar!\n";
while (<FH>){
chomp;
defined $parser->startrule($_) or print "Bad text!\n";
}
--------------------------------------------------------------------------------
HTH,
Damian
------------------------------
Date: 22 Jul 1999 21:19:43 -0500
From: Kent Perrier <kperrier@blkbox.com>
Subject: Re: Perl Math Calculation vs. FORTRAN Calculations
Message-Id: <26170A383BDB486A.9B56A9B93ABC6D2D.265E6D2946EB8996@lp.airnews.net>
Scott Dummer <scott.dummer@noaa.gov> writes:
> I have wrote a series of equations to calculate something (like the
> distance on an oblate spheroid "earth") in FORTRAN and perl.
Perhaps you should write a news reader that doesn't post you message
three times.
Kent
------------------------------
Date: 23 Jul 1999 02:30:17 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl Math Calculation vs. FORTRAN Calculations
Message-Id: <7n8k3p$o1c$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Larry Rosler
<lr@hpl.hp.com>],
who wrote in article <MPG.1200d7a51fcf3577989d19@nntp.hpl.hp.com>:
> One likely source of the difference is the order of evaluation of
> complex expressions. Fortran is required to honor parentheses, so
>
> (a + b) + c
>
> and
>
> a + (b + c)
>
> may give different results because of loss of significance if two of the
> numbers are close in magnitude but opposite in sign. On the other hand,
> C isn't required to honor the parentheses.
My reading of Kahan's (sp?) papers is that (due to pressure from
numeric-calculations communinty) C has sane rules for numeric
calculations: order of evaluation is honored for floating-point data.
> I would assume Perl is like
> C in this respect -- a test would resolve this.
Perl has no optimizer (to speak of), thus it will also do calculations
as the parser emited them.
> But fundamentally you are asking too much of either language. Even
> within one programming language, comparing floating-point numbers that
> are the results of calculations for absolute equality is like asking
> whether the numbers of grains of sand in two piles is the same. You'll
> never know, and you shouldn't care. Comparing the results from *two*
> languages for absolute equality is utter folly.
If a language is sane, the result of evaluation of any expression
should be predictable (unfortunately, Perl is not sane). Similarly,
given the same mapping to hardware types (say, same IEEE modes),
results of numeric calculations should be the same. (Having different
IEEE modes of x86 for registers and memory variables may make things
funnier.)
Ilya
------------------------------
Date: Thu, 22 Jul 1999 17:23:48 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: perl vs. FORTRAN Caculations
Message-Id: <3797B614.C124A8C7@mail.cor.epa.gov>
Scott Dummer wrote:
>
> I have written a series of equations to perform some distance calculations
> in both perl and FORTRAN. The results differ slightly (by 0.3%, or 161m).
> This is very uncomforting to me. Both programs use the exact same
> constants and equations, although the FORTRAN is using implicit double
> precision. I am not using anything special in perl other than what is
> basic in version 5.005_03. I tend to trust what the FORTRAN is giving
> over perl, since FORTRAN's strength is in accurate quick number crunching,
> although if I could get the a % difference of around .03% I would use the
> perl script. Any help would be very much appreciated.
Hmmm. Given the underlying properties of the two languages,
I would be quite shocked to get a difference this large, unless
something in your order of calculations is causing a massive
loss of significant digits somewhere along the line.
In the past, when I have had a problem like this, it is far
more likely to be a typo that I made, than a massive failure
in a well-known program or programming language.. unless
you're using a Pentium, of course. :-)
May I suggest a ton of print() statements? The way I have
discovered the error of my ways in such cases was to run both
programs with lots of intermediate print()s so that I could
follow the logic flow and track the intermediate values,
until... lo and behold, I found that 3.1415926 was accidentally
typed in as 3.145926 in the other program. Yikes.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Fri, 23 Jul 1999 00:40:27 GMT
From: Tim Cull <trcull@my-deja.com>
Subject: POSIX module
Message-Id: <7n8dlp$9sv$1@nnrp1.deja.com>
Can anyone tell me where on the web to find a simple list of all the
functions in the POSIX module and a short description of what they do?
For that matter, can anyone tell me where to find lists of the functions
of any arbitrary module? I've been able to find plenty of lists of
modules, but no lists of the contents of modules, which is very
frustrating.
thanks,
Tim Cull
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 22 Jul 1999 19:06:25 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: POSIX module
Message-Id: <3797c011@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
Tim Cull <trcull@my-deja.com> writes:
:Can anyone tell me where on the web to find a simple list of all the
:functions in the POSIX module and a short description of what they do?
:For that matter, can anyone tell me where to find lists of the functions
:of any arbitrary module? I've been able to find plenty of lists of
:modules, but no lists of the contents of modules, which is very
:frustrating.
You have to read the modules' manpages, of course.
--tom
--
A woman needs a little more weird today than normal. --Andrew Hume
------------------------------
Date: 22 Jul 1999 21:34:56 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: POSIX module
Message-Id: <slrn7pfl5a.1a1.abigail@alexandra.delanet.com>
Tim Cull (trcull@my-deja.com) wrote on MMCLII September MCMXCIII in
<URL:news:7n8dlp$9sv$1@nnrp1.deja.com>:
== Can anyone tell me where on the web to find a simple list of all the
== functions in the POSIX module and a short description of what they do?
== For that matter, can anyone tell me where to find lists of the functions
== of any arbitrary module? I've been able to find plenty of lists of
== modules, but no lists of the contents of modules, which is very
== frustrating.
For a module called 'Module::Foo', all you need to do is:
man Module::Foo
Amazing, isn't?
HTH. HAND.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'
-----------== 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: 23 Jul 1999 02:44:52 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Prime Factorization
Message-Id: <7n8kv4$o44$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to V. Balaji
<balaji@cray.com>],
who wrote in article <7mq73b$i9v$1@murrow.corp.sgi.com>:
> >Does anyone know how to write a perl script for finding the prime
> >factorization of a number?
>
> Do you need a perl script? What's wrong with factor(1)?
>
> One of the MTOWTDI is generally not to use perl.
Right:
time perl -MMath::Pari=:int,factorint -wle 'print factorint 123547126354816454331713
[7,1;107458296329,1;164245945471,1]
0.44u 0.22s 0:02.81 23.4%
time factor 123547126354816454331713
factor: `123547126354816454331713' is not a valid positive integer
Try `factor --help' for more information.
0.00u 0.02s 0:00.02 100.0%
Note how quickier is factor(1) to report its results!
Ilya
------------------------------
Date: Thu, 22 Jul 1999 20:13:22 -0400
From: Steve Palincsar <palincss@his.com>
Subject: Re: Problem compiling 'write'
Message-Id: <3797B3A1.3F6C940F@his.com>
You do recall that "while" is not in initial caps...?
>While (<STDIN>) {
> ( $RecCode, $CustGroup, $OrigType, $OrigId, $InfoDigits,
> $ConsNum, $SubGrp, $TermType, $TermId, $RouteInfo, $JulianDate,
> $Time, $Duration, $OrgFC, $TermFC, $Called ) =
> split (/:/);
> write;
>}
Once I fixed that it compiled just fine.
Robert Rawlinson wrote:
>
> I am new to Perl. I wrote the following program borrowing heavily from
> code in the perl camel See attachment.
>
> When I compile I get the message:
> syntax error at tsmdrrport.pl line 26, near "write"
> Execution of tsmdrrport.pl aborted due to compilation errors.
>
> I can't seem to understand what is wrong. Can anyone help?
>
> --
> Robert A. Rawlinson
------------------------------
Date: Thu, 22 Jul 1999 22:16:12 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: problem with hash of arrays
Message-Id: <1dvd4ww.16la62y5osnlsN@p5.tc14.metro.ma.tiac.com>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> I don't know about MLDBM, but any the modules I know that tie
> hashes to a database will stringify references before storing
> them away, which makes them useless. The following bit demonstrates
> this:
Obviously you don't know about MLDBM. The ML is for multi-level; it is
specifically designed to allow storage and retrieval of multi-level data
structures.
> Unless the MLDBM documentation explicitly says otherwise, I wouldn't
> trust it to handle references correctly.
The MLDBM documentation explicitly says otherwise. That's the whole
point of MLDBM.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 22 Jul 1999 22:02:42 -0400
From: Gary Nielson <gnielson@charlotte.infi.net>
Subject: Question about troubleshooting mirror.pl
Message-Id: <3797CD42.7ABD5862@charlotte.infi.net>
Can anyone explain why I can successfully mirror many virtuals, but not
others with mirror.pl v 2.8. I suspect it has something to do with the
operating system and web server I am attempting to mirror. When I try to
access a few sites, I get the message Skipping site because it is this
local site! Which of course it is not. I noticed in the mirror.pl code
that this error message is invoked when the site hostname equals the
receiving computer's hostname, which can't be in my cases. I've tried
recurse_hard toggling on and off, and adding a variety of different
parameters and toggling them in mirror.defaults, all without success.
Suggestions?
Thanks. Please email reply as well.
Gary
------------------------------
Date: Thu, 22 Jul 1999 17:57:23 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Retrieving NT Services
Message-Id: <3797BDF3.63B46FEE@mail.cor.epa.gov>
Larry Rosler wrote:
> [snip of text except for an illustrative example]
> > > I use Win32::Lanman to get not only the service
> > and it's status, but
> > Where did you find lanman? ppm doesn't find it.
> [and more snippage]
>
> > Sent via Deja.com http://www.deja.com/
> > Share what you know. Learn what you don't.
>
> Has anyone else noticed this rash of weirdly wrapped postings, with
> ridiculously short line lengths? Is it a disease at Deja.com, or what?
deja.com *is* the disease. You're just seeing another symptom.
Maybe they could change their slogan to:
"Infect with what you carry. Become infected with what you don't."
Catchy, huh?
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Thu, 22 Jul 1999 17:47:59 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: searching man pages, perldoc's, FAQ's, README's, HOWTO's, etc.
Message-Id: <3797BBBF.14034355@mail.cor.epa.gov>
David Christensen wrote:
> [snip!]
> Sounds like just what the doctor ordered! :-)
>
> Do you know if there's a port of TkMan, PolyglotMan, and/or Tcl/Tk
> for Windows?
There's a less-powerful version in Perl, written in the
"Advanced Perl Programming" book, with (IIRC) code available
at the O'Reilly site. You can always make it more powerful
yourself, and then submit it to CPAN...
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Thu, 22 Jul 1999 22:16:13 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: setuid and opening a file for writing
Message-Id: <1dvd63u.5z4cbu1wbpoxsN@p5.tc14.metro.ma.tiac.com>
Mark Francis <mark@NO-SPAM.lavalink.com.au> wrote:
> Thanks for the info. Unfortunately, yes, $new_file is already being
> untainted earlier on with:
>
> if ($new_file =~ /^([a-zA-Z0-9\-_\.]+)$/) {
> $new_file = $1;
> } else {
> ...
>
What's in the else? Does your script report an error if the regex does
not match?
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 23 Jul 1999 02:44:48 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: TextArea fields
Message-Id: <7n8kv0$8$1@lublin.zrz.tu-berlin.de>
<lefkogt.xp@usafa.af.mil> wrote in comp.lang.perl.misc:
>How can we use textarea fields in forms so that people can put hard
>carriage returns to separate paragraphs in a textarea field? Everytime
>we do it now it adds extra record(s) per physical carriage return.
Who is the "it" that adds extra records? A cgi script written in perl?
You don't give us much to work with. What did you try to make a single
record from a multi-line entry? How about
$description_of_idea =~ s/\r\n/ /g
(or whatever the name of the variable is that holds the content
of that text field)? Just an educated guess.
> We
>are on Unix-flavor server. Try it at www.home-bytes.com/stratplan/ .
>Click on Mission Analysis link,
So why don't you give us that url?
> notice record count, click Add, enter
>info , enter hard carriage returns (enter key) in first textarea ONLY
>for now. If you enter say three of them you will see four records were
>generated when you return to the main database screen (look at new
>count).
Sheesh, there's a lot more wrong with that page than that it produces
empty database entries. Just for one, instructions on how to use a
field don't belong in the preset text of the field. You'll get quite
a few entries with title "Title Field Is Mandatory" if you do that.
> The program is an iteration of a database (ASCII) program
>built by Brent Michalski from www.webreview.com. If you need to see
>code let me know and I will email it to you.
We do need to see some code. Extract the part that deals with the
contents of that particular text area and post it. Then we'll see.
Anno
------------------------------
Date: Fri, 23 Jul 1999 01:00:19 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: waitpid crashes perl
Message-Id: <FFAtGJ.884@news.boeing.com>
In article <01bed446$b3375620$918ee226@phdye-laptop>,
Philip H. Dye <Philip_Dye@norstanconsult.com> wrote:
>Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in article
>> Yes. Perl isn't reentrant and malloc() (perl's or other) is a
>particularly
>> likely candidate.
>>
>> >Has anyone run into this behavior before ? Any known work arounds ?
>>
>> A suggested workaround is to do as little as possible in the signal
>> handler, for instance just set a preset variable (not an undefined
>> one). Of course, the main program will have to check that variable
>> periodically and act accordingly, which can be a nuisance to do.
>
>My signal handler is nearly a copy of the one on page 340 of Programming
>Perl.
>
>sub reaper
>{
> my $child ;
>
> while ( $child = waitpid(-1,WNOHANG) )
> {
> $Child_Status { $child } = $? ;
> }
>}
Are you perhaps referring to the Prehistoric Camel? There's
something like that on Pg. 350 which goes:
sub reapchild {
while (1) {
print "Reaping child\n";
$pid = waitpid(-1, $WNOHANG):
---> last if ($pid < 1);
$service = $serviceof{$pid};
...
I've marked the key part, missing from your code, which
will prevent looping. See waitpid(2).
But, some of the other Camel code isn't safe, especially
C<print>. Even, if you've pared out the print, the
C<$my child> should be moved outside the handler.
One possibility is just to set a flag in the handler and
then flag check and C<waitpid> somewhere outside. Deferring
the reap may be problematic too though if you're
forking large numbers.
hth,
--
Charles DeRykus
------------------------------
Date: Thu, 22 Jul 1999 17:30:00 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: What is the best way to write data to a com port under DOS.
Message-Id: <3797B788.288C0C52@mail.cor.epa.gov>
Joeri Belis wrote:
>
> What is the best way to write data to a com port under DOS.
>
> the baud rate must be 9600. How can i set this in a perl program
I would recommend Bill Birthisel's Win32::SerialPort module.
You can get it from CPAN.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Fri, 23 Jul 1999 12:02:48 +1000
From: "Ron Savage" <ron_savage@non-hp-australia-om5.om.hp.com>
Subject: Re: What is the best way to write data to a com port under DOS.
Message-Id: <7n8ipi$goc$1@ocean.cup.hp.com>
There's a module: Win32::SerialPort.
--
Cheers
Bus: rons@hpaco.aus.hp.com
Home: ron@savage.net.au
http://savage.net.au/
Joeri Belis wrote in message <7n7g8b$oht$1@xenon.inbe.net>...
>What is the best way to write data to a com port under DOS.
>
>the baud rate must be 9600. How can i set this in a perl program
>
>joe
>
>
>
------------------------------
Date: Thu, 22 Jul 1999 22:07:10 -0400
From: "Paul Popour" <ppopour@infoave.net>
Subject: Win32::EventLog
Message-Id: <7n8iqe$i41$1@news3.infoave.net>
Does anyone have any sample code of reading the entire message from an event
log entry?
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
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 V9 Issue 231
*************************************