[12313] in Perl-Users-Digest
Perl-Users Digest, Issue: 5913 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 7 15:07:22 1999
Date: Mon, 7 Jun 99 12:00:24 -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 Mon, 7 Jun 1999 Volume: 8 Number: 5913
Today's topics:
Re: (multithread) lock & unlock? <sugalskd@netserve.ous.edu>
[Question]: Finding a file pattern (VGOEL)
Re: a problem with open( ,system()) <jeromeo@atrieva.com>
ANNOUNCE: PerlMonth - Issue 2 baiju12@my-deja.com
Re: awk history - 1 based indexing <monty@primenet.com>
Re: Coloring text in DOS console? <fruffet@kaptech.com>
Re: DBD::ODBC (Dan Wilga)
Re: Help with date function... (Larry Rosler)
Re: how do i fucking run perl w32 <jhcw@doc.ic.ac.uk>
Installing Embperl with Red Hat 5.2 krisandrews@my-deja.com
Re: Is perl useful for me? <gbartels@xli.com>
Re: is this code clunky? mikecard@my-deja.com
Key mappings frednerd1@my-deja.com
Re: know Perl to maintain Perl (was: Re: I pass an arra (Greg Andrews)
Re: Log Reader Utility (Brad Knowles)
ModPerl and memory consumption <clint@drtech.co.uk>
NT perl question(probably simple) <perini@buffalo.edu>
Re: NT perl question(probably simple) (Larry Rosler)
Re: Perl and Databases vbaddour@my-deja.com
Possible compiler error when passing associative array <pasquali@uthscsa.edu>
Possible compiler error when passing associative arrays <pasquali@uthscsa.edu>
Possible compiler error when passing associative arrays <pasquali@uthscsa.edu>
Re: Possible compiler error when passing associative ar (Larry Rosler)
Re: Regular Expressions <garethr@cre.canon.co.uk>
Signal/sleep hidden interaction? dhosek@quixote.com
Syntax for square roots? <user@nowhere.com>
Re: Syntax for square roots? (Larry Rosler)
Re: The artistic license and perl: <gbartels@xli.com>
unimplemented functions (Tim Herzog)
Re: unimplemented functions (Mark-Jason Dominus)
Re: unimplemented functions <jeff@vpservices.com>
Re: XS: Overriding errno? (Elf Sternberg)
Re: XS: Overriding errno? <sugalskd@netserve.ous.edu>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 7 Jun 1999 18:35:21 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: (multithread) lock & unlock?
Message-Id: <7jh3d9$f0s$2@news.NERO.NET>
GEMINI <dennis@info4.csie.nctu.edu.tw> wrote:
: the perldoc Thread
: provides too few information
: to understand the multithread programming on perl.
: If I wish to synchronize the access to
: a variable, how should I do?
: the document only mentioned about "lock" function,
: but how about "unlock"? Is there an unlock function?
Nope. Anything you lock() is automatically unlocked when the lock goes out
of scope. For example:
{
$a = 12;
{
lock($a);
# $a is locked here
} # This ends the scope of the lock, so after this point
# $a is unlocked
}
: besides, can I find any sample for the perl
: multithread programming on the internet?
Well, there's the perlthrtut doc that comes with 5.005_03, but that's
about it at the moment.
Dan
------------------------------
Date: 07 Jun 1999 10:20:17 PDT
From: Vgoel@cris.com (VGOEL)
Subject: [Question]: Finding a file pattern
Message-Id: <7jgv0h$125@chronicle.concentric.net>
Hello all;
I am at my wits end. I have checked the FAQs, the Perl Cookbook and the
Camel book but I cannot figure out how to do this. I am basically calling a
sub like ProcessArgs($dirname, $filepat). Here is the code snippet of
ProcessArgs:
sub ProcessArgs {
my @x = split (/\;/, $_[0]);
my $i;
foreach $i (@x) {
print "checking $i\n";
opendir(DH, $i);
my @files;
my @files = glob("$_[1]");
print "@files\n";
closedir(DH);}
}
But this does not seem to work. This code should basically sniff out the
$_[0] dir for all patterns matching $_[1] and return the $_[1]. I know I am
a morono so please point me to the right direction for tackling this
problem.
Thanks
--
--[Vaibhav Goel]-[vgoel@concentric.(remove.to-email).net]
[ http://www.concentric.net/~vgoel ][ '83 Suzuki GS650G ]
["Take Control of the machine now!" -- Utah Saints]
------------------------------
Date: Mon, 07 Jun 1999 10:34:17 -0700
From: Jerome O'Neil <jeromeo@atrieva.com>
To: ZENG <zeng@haas.Berkeley.EDU>
Subject: Re: a problem with open( ,system())
Message-Id: <375C0299.DF61E3FC@atrieva.com>
ZENG wrote:
> # open (PROG, "$temp |"); #this 'open' works fine.
> open (PROG, "system(who) |"); #don't work. don't know why
> Please note that I have two lines in the code which use 'open'. The first
> one works perfectly, but the second one which plugs the system call there,
> it fails to compile (of course, every time I comment one 'open' out and
> use only one. And if I use 'system(who)' separately (i.e., not a part of
> the 'open'), it works fine too. What did I miss here?
I think you are missing the documentation for system(). You can use
either system() or open() to accomplish what you want, but not together
(at least in any desirable way of which I can think.) Read perldoc -f
system, and ask yourself "What will open() do with the return value of
system()?"
For all the exciting detail on system(), fork() and exec(), read the
appropriate pages in the perlfunc document that came with your perl
distribution. For mode detail on processes and process communication,
read the perlipc document that came with your perl distribution.
Good Luck!
--
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947
The Atrieva Service: Safe and Easy Online Backup http://www.atrieva.com
------------------------------
Date: Mon, 07 Jun 1999 16:36:54 GMT
From: baiju12@my-deja.com
Subject: ANNOUNCE: PerlMonth - Issue 2
Message-Id: <7jgsf5$rsu$1@nnrp1.deja.com>
The second issue of PerlMonth is now available at
http://www.perlmonth.com/
The Second issue contains the following articles:
Author Title
Vicki Brown MacPerl Oddities: if ($^O == 'MacOS')
Paul Vininig Creating Dynamic Pages With Embperl
Steven McDougall Finding your files with File::Find
Dave Cross Modules, References, Data Structures and Objects
Stas Bekman What is mod_perl?
Slaven Rezic An application with perl/Tk: tkgnuplot
Kurt Starsinic Uses of Autoload
Doug MacEachern Interactive Perl Debugging under mod_perl
We need your feedback to make PerlMonth serve you better.
feedback@perlmonth.com
Thank you and Enjoy !
Baiju Thakkar
Just use Perl;
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 7 Jun 1999 18:57:42 GMT
From: Jim Monty <monty@primenet.com>
Subject: Re: awk history - 1 based indexing
Message-Id: <7jh4n6$59v$1@nnrp02.primenet.com>
[Crossposted to comp.lang.perl.misc]
In comp.lang.awk, Peter S TIllier wrote:
> In comp.lang.awk, Harlan Grove wrote:
> > In comp.lang.awk, Bob Nelson wrote:
> > >
> > > Why did Aho and company choose 1-based indexing (aside from ARGV in
> > > newer awk implmentations) for arrays rather than the more logical
> > > 0-based approach as used in C?
> >
> > The point I'll infer from the original poster is that awk's split()
> > creates arrays indexed from 1 to n, where n is the number of array
> > elements split() creates. Awk needs to start array indices somewhere.
>
> Yes I agree with you and Jim Monty that this was what the original post was
> about. As Jim says it keeps in line with the line splitting into $1, $2,
> etc.; so is probably easier to follow.
In Perl, the array index of the first element is configurable.
Here's an excerpt from the perlop man page (``$['' is the identifier
of the built-in variable):
$[ The index of the first element in an array, and of the first
character in a substring. Default is 0, but you could set it
to 1 to make Perl behave more like awk (or Fortran) when
subscripting and when evaluating the index() and substr()
functions. (Mnemonic: [ begins subscripts.)
As of Perl 5, assignment to ``$['' is treated as a compiler
directive, and cannot influence the behavior of any other
file. Its use is discouraged.
It might be instructive to know why "[i]ts use is discouraged" by
the author of the man page (probably Tom Christiansen).
--
Jim Monty
monty@primenet.com
Tempe, Arizona USA
------------------------------
Date: Mon, 7 Jun 1999 18:21:54 +0200
From: "Fred Ruffet" <fruffet@kaptech.com>
Subject: Re: Coloring text in DOS console?
Message-Id: <7jgrjc$vk7$1@gatekeeper.ornano.kapt.com>
He, he, he !!!
Now I have the help page. In your favorite MS-DOS shell, type "help
ANSI.SYS" (wether ANSI.SYS is declared in your CONFIG.SYS).
Then, you'll find the escape codes to send... and your MS-DOS shell will be
colored !
Good luck,
Fred,
------------------------------
Date: Mon, 07 Jun 1999 14:10:14 -0400
From: dwilgaREMOVE@mtholyoke.edu (Dan Wilga)
Subject: Re: DBD::ODBC
Message-Id: <dwilgaREMOVE-0706991410140001@wilga.mtholyoke.edu>
I'm no expert on this topic, but I think that depending on how the DB is
set up, you may need to "commit" the change.
In article <7jgqb5$u92@news.vtcom.fr>, "Ysteric's" <eyounes@aol.com> wrote:
> Is there anybody to help me ?
>
> I use DBD::ODBC to manage an access table.
>
> My problem is for the delete. When i do
>
> $sql = qq{DELETE FROM TBL WHERE NAME=?};
> if ( $dbh->do($sql, undef, $FORM{'name'})) {
> print "OK, it works";
> } else {
> print "What ???";
> }
>
> it seem's to work quite well, but the line is still alive in my table !
>
> Did i miss somthing ?
>
> thanks everybody.
>
> Eric From FRANCE
Dan Wilga dwilgaREMOVE@mtholyoke.edu
** Remove the REMOVE in my address address to reply reply **
------------------------------
Date: Mon, 7 Jun 1999 10:32:19 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help with date function...
Message-Id: <MPG.11c5a20143460ce8989b81@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <375B89F9.9AD50241@home.com> on Mon, 07 Jun 1999 16:56:49
GMT, Mitch <portboy@home.com> says...
> Okay, I'm working on a BSD 4.0.1 box, and I'm trying to setup a simple
> little script that will set the date. Here's some code: The parameters
> passed to the subroutine will be either "date set" or "date (shows the
> date/time)". For some reason, none of my "do while" loops are working.
> They all seem to pass through on any input. Can someone help me out and
> tell me why? ...
...
> do
> {
> $year = &get_it("Enter the year: ", "1999");
> &show("Year is $year\n");
> } while ($year >= 1999);
I think you mean "do { ... } until ( ... )", here and in all the other
tests.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 07 Jun 1999 18:16:39 +0100
From: Jonathan Wilson <jhcw@doc.ic.ac.uk>
To: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: how do i fucking run perl w32
Message-Id: <375BFE77.443627B1@doc.ic.ac.uk>
>
> > i just got ActivePerl517. when i run any of the sample scripts, the dos
> > window opens quickly then closes. i don't know what the programs do or how
> > to run my own programs. can somebody help me please.
I'm no expert (at all at all) but if I remember right, after typing "perl
script.pl >feck" you can load "feck" into your browser.
Jonathan.
------------------------------
Date: Mon, 07 Jun 1999 17:08:21 GMT
From: krisandrews@my-deja.com
Subject: Installing Embperl with Red Hat 5.2
Message-Id: <7jgu9s$sks$1@nnrp1.deja.com>
I'm a novice at configuring Linux and Apache, but I did manage to get
mod_perl working on a Red Hat 5.2 installation. Seemingly RH puts its
files in a different place than the standard mod_perl installation; and
RH uses .so files, not recompiled source files.
I managed to get mod_perl working because it shipped with RH 5.2.
However, as far as I can tell Embperl does not ship with RH. The .tar
files all over the net look for an Apache filesystem that's different
from RH's default installation. In order to run the standard series of
make's to install Embperl - if I'm reading this correctly - I'd have to
build a new directory tree for Apache and recompile the whole thing,
including mod_perl. Correct?
Now, mod_perl has a .so file in the standard RH 5.2 distribution. Am I
correct in assuming that a similar .so file for Embperl would be
sufficient to install it? If so, does anyone know where I can get it?
If not, can anyone shed some more light on how I can install Embperl on
a standard RH 5.2 installation?
(I'm hesitant to depart from the standard install, since the resulting
Apache site may need to be duplicated over several dozen servers.)
Thanks!
- Kris Andrews
- Developer, world.hire
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 07 Jun 1999 12:36:03 -0400
From: Greg Bartels <gbartels@xli.com>
Subject: Re: Is perl useful for me?
Message-Id: <375BF4F3.16D2FE84@xli.com>
Paulo da Silva wrote:
>
> I'm considering learning perl, but only if GUIs are
> supported. Would anyone pls, tell me if GUI interfaces
> are possible with "pure" perl and how easy (or difficult)
> it is to build a GUI.
>
> TIA
>
> --
> Please remove the anti-spam Xs from my email address.
> PF. retirar os Xs anti-spam do meu endereco de email.
"Advanced Perl Programming" by Sriram Srinivasan or
"Learning Perl/Tk" by Nancy Walsh
(both published by oreilly)
are good books for learning how to do gui stuff in perl.
Tk is the perl graphical "ToolKit", to explain the acronym.
it is _ungodly_ easy to do gui's in perl.
I use it at work a lot, making one-off tools for engineering
use. it is perfect. I spend most of my time doing engineering
and very little time getting perl/tk to do what I want.
here's the hello world example, it will pop up a gui panel
with a button on it.
#!/usr/bin/perl
use Tk;
my $mw = MainWindow->new;
$mw->title('hello world');
$mw->Button(-text => 'done', command => sub {exit}) -> pack;
MainLoop;
newsgroup: comp.lang.perl.tk
is available to answer technical questions.
Greg
------------------------------
Date: Mon, 07 Jun 1999 16:26:19 GMT
From: mikecard@my-deja.com
Subject: Re: is this code clunky?
Message-Id: <7jgrqv$rlo$1@nnrp1.deja.com>
In article <x77lpg853h.fsf@home.sysarch.com>,
Uri Guttman <uri@sysarch.com> wrote:
> @card_seq = qw(2 3 4 5 6 7 8 9 10 J Q K A);
> @suit_seq = qw( diamonds hearts clubs spades ) ;
>
> $suit_played = $card / 13 ;
> $card_played = $card % 13 ;
>
> print "card played is $card_seq[$card_played] of
$suit_seq[$suit_played]\n";
>
> uri
totally awsome! thank you Uri, i had wondered what the modulus (%)
operator was good for (when i read about it i though it was something
for super advanced physics stuff...i never imagined it would be useful
for a card game) thanks again.
mike cardeiro
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 07 Jun 1999 16:04:18 GMT
From: frednerd1@my-deja.com
Subject: Key mappings
Message-Id: <7jgqhq$r6e$1@nnrp1.deja.com>
Hi All,
Off the bat I'll say I'm a PERL novice.
What I would like to do is read input from the
keyboard and find what the (function) key is
mapped to, ie i'm writting a new termcap entry
but two function keys are not working and I want
to know what escape sequence is being issued when
I press the key.
Tips would be preferred so I can try and work out
the program myself, but I'll accept anything.
Please reply via email as my work doesn't have
news access.
Thanks,
Jason
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 7 Jun 1999 11:22:58 -0700
From: gerg@shell1.ncal.verio.com (Greg Andrews)
Subject: Re: know Perl to maintain Perl (was: Re: I pass an array...)
Message-Id: <7jh2m2$fsp$1@shell1.ncal.verio.com>
Greg Bacon <gbacon@cs.uah.edu> writes:
>In article <1dsxx9n.xzbbkf3h8s66N@[207.60.170.186]>,
> rjk@linguist.dartmouth.edu (Ronald J Kimball) writes:
>: Of course, "off-limits" is not the best term here. If you can explain
>: all the Perl code/English speech/Liszt music such that the Visual
>: BASIC/Polish/harmonica immigrants can understand it, then none of it is
>: off-limits. If you can't explain it, you can still use it, as long as
>: none of the immigrants are expected to understand it.
>
>I believe you've built a straw man. If the very author of the code in
>question can't explain it, it isn't likely to be maintainable anyway.
>
I agree, modulo the author's abilities as a guru as contrasted with
his/her abilities as a wizard.
The definition of a guru and wizard I heard many years ago is a
good one:
A wizard can work the magic.
A guru can explain the magic.
I've encountered people who could write good code, but had
trouble with mentally shedding their knowledge base in order
to properly frame the explanation for the student.
-Greg
------------------------------
Date: Mon, 07 Jun 1999 19:00:11 +0200
From: brad@shub-internet.org (Brad Knowles)
Subject: Re: Log Reader Utility
Message-Id: <brad-0706991900110001@brad.techos.skynet.be>
In article <4sS63.295$up4.603@news.flash.net>, "Mike Grimes"
<megrimes@flash.net> wrote:
> I have a number of (UNIX/AIX) applications which generate individual log
> files. I am looking for a public domain tool which can be configured to read
> multiple log files and send email or a page depending on text messages
> entered in these log files. Ideally, it will be written in PERL so that it
> might be easily ported/used with NT boxes also. A tool like this must exist
> somewhere, does anyone have experience with such a utility?
Many of the programs at
<http://www.freshmeat.net/appindex/console/log-analyzers.html> and
<http://online.linuxberg.com/conhtml/adm_log.html> are written in Perl.
--
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>
<http://wwwkeys.pgp.net:11371/pks/lookup?op=get&search=0xE38CCEF1>
------------------------------
Date: Mon, 07 Jun 1999 19:18:46 +0100
From: Clinton Gormley <clint@drtech.co.uk>
Subject: ModPerl and memory consumption
Message-Id: <375C0D05.BCD5601F@drtech.co.uk>
I have recently built mod_perl with apache 1.3.6 using DSO.
I have been suprised by how much memory each httpd process consumes.
Maybe I'm just misunderstanding this?
Without mod_perl, each httpd process takes approx 1 meg. With mod_perl,
each process takes about 3.5 meg, and when you preload a few perl
modules on startup (eg CGI.pm, Apache::DBI) this takes it up to 7.5 meg
per process!
I have just noticed that if I do "apachetctl restart", it seems to add
about 2.5 meg onto each process (so 7.5 becomes 10 becomes 12.5 etc)
This seems to be caused by the Perl modules that I load in my startup
file.
If I stop the server and then restart, it resets itself to 7.5 meg.
I thought that Perl modules which you loaded at the beginning were
supposed to be shared between all the child processes (ie without
consuming more memory)
Have I got this wrong?
Thanks
Clinton Gormley
------------------------------
Date: Mon, 7 Jun 1999 14:07:11 -0400
From: "Bob Perini" <perini@buffalo.edu>
Subject: NT perl question(probably simple)
Message-Id: <7jh21l$eh8$1@prometheus.acsu.buffalo.edu>
I'm trying to print this information out for a changing error message.
sub addtodberror
{
$error=$_[0];
print "content-type: text/html\n\n";
print "<HTML>\n";
print "<BODY bgcolor=white>\n";
print "You forgot to fill out the",$error,"form.<BR>\n";
print "Please press the back button on your browser.\n";
print "</BODY>\n";
print "</HTML>\n";
}
This is being called by another function and it doesn't seem to print out
the $error variable.
Any ideas? I'm using winNT, I've got this to work in Unix before, but it
doesn't seem to work in NT...
Thanks,
--
Bob Perini
------------------------------
Date: Mon, 7 Jun 1999 11:44:22 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: NT perl question(probably simple)
Message-Id: <MPG.11c5b2deea0860df989b85@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7jh21l$eh8$1@prometheus.acsu.buffalo.edu> on Mon, 7 Jun 1999
14:07:11 -0400, Bob Perini <perini@buffalo.edu> says...
> I'm trying to print this information out for a changing error message.
>
> sub addtodberror
> {
> $error=$_[0];
> print "content-type: text/html\n\n";
> print "<HTML>\n";
> print "<BODY bgcolor=white>\n";
> print "You forgot to fill out the",$error,"form.<BR>\n";
> print "Please press the back button on your browser.\n";
> print "</BODY>\n";
> print "</HTML>\n";
> }
>
> This is being called by another function and it doesn't seem to print out
> the $error variable.
> Any ideas? I'm using winNT, I've got this to work in Unix before, but it
> doesn't seem to work in NT...
There's absolutely nothing there that would be different from Unix to
NT. Maybe you have a server problem.
But wouldn't the following be a nicer way to write it in any case?
sub addtodberror
{
print <<HTML;
content-type: text/html
<HTML>
<BODY bgcolor=white>
You forgot to fill out the $_[0] form.<BR>
Please press the back button on your browser.
</BODY>
</HTML>
HTML
}
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 07 Jun 1999 17:15:30 GMT
From: vbaddour@my-deja.com
Subject: Re: Perl and Databases
Message-Id: <7jgun8$sr6$1@nnrp1.deja.com>
In article <37452ff8.6763695@news.mmu.ac.uk>,
W.Peel@mmu.ac.uk (Bill Peel) wrote:
> Get Dave Roth's Win32::ODBC module and then look
at the tutorial at
> the URL:
>
>
http://www.netaxs.com/~joc/perl/article/Article.ht
ml
>
Okay- how about a way to access a MS SQL database
using perl on a unix based machine?
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 7 Jun 1999 13:10:16 -0500
From: "Lee Pasquali" <pasquali@uthscsa.edu>
Subject: Possible compiler error when passing associative array
Message-Id: <7jh1ss$doj$1@cosmos.uthscsa.edu>
I am converting a perl cgi from perl-v5.001 to perl-v5.005_03. The cgi
contains code simular to that listed below.
local ($a, $b, $c, %assoc);
$a = "a";
$b = "b";
$c = "c";
$assoc{one} = "11";
$assoc{two} = "22";
&print_values($a, $b, %assoc, $c);
sub print_values
{
local($sub_a, $sub_b, %sub_assoc, $sub_c) = @_;
print " value passed #1 **$_[0]**\n";
print " value passed #2 **$_[1]**\n";
print " value passed #3 **$_[2]**\n";
print " value passed #4 **$_[3]**\n";
print " value passed #5 **$_[4]**\n";
print "\n\n";
print " sub_a **$sub_a**\n";
print " sub_b **$sub_b**\n";
for $key (keys %sub_assoc)
{
print " sub_assoc - Key: $key Value: $sub_assoc{$key}\n";
}
print " sub_c **$sub_c**\n";
return;
}
When this code is executed by perl-v5.001 the following results are
obtained.
value passed #1 **a**
value passed #2 **b**
value passed #3 **two**
value passed #4 **22**
value passed #5 **one**
sub_a **a**
sub_b **b**
sub_assoc - Key: one Value: 11
sub_assoc - Key: two Value: 22
sub_c **c**
When the code is executed by perl-v5.005_03 the following incorrect results
are obtained.
value passed #1 **a**
value passed #2 **b**
value passed #3 **two**
value passed #4 **22**
value passed #5 **one**
sub_a **a**
sub_b **b**
sub_assoc - Key: one Value: 11
sub_assoc - Key: two Value: 22
sub_assoc - Key: c Value:
sub_c ****
As one can see, perl has a bug such that it does not find the end of the
associative array correctly in the subroutine.
Has anyone else seen this bug?
Does anyone know where I can obtain a buglist and patches for v5.005_03?
Does this bug exist in versions previous to v5.005_03?
Who do I notify that this bug exists?
Thanks for any help in advance!
------------------------------
Date: Mon, 7 Jun 1999 13:07:59 -0500
From: "Lee Pasquali" <pasquali@uthscsa.edu>
Subject: Possible compiler error when passing associative arrays
Message-Id: <7jh1oj$dqg$1@cosmos.uthscsa.edu>
I am converting a perl cgi from perl-v5.001 to perl-v5.005_03. The cgi
contains code simular to that listed below.
local ($a, $b, $c, %assoc);
$a = "a";
$b = "b";
$c = "c";
$assoc{one} = "11";
$assoc{two} = "22";
&print_values($a, $b, %assoc, $c);
sub print_values
{
local($sub_a, $sub_b, %sub_assoc, $sub_c) = @_;
print " value passed #1 **$_[0]**\n";
print " value passed #2 **$_[1]**\n";
print " value passed #3 **$_[2]**\n";
print " value passed #4 **$_[3]**\n";
print " value passed #5 **$_[4]**\n";
print "\n\n";
print " sub_a **$sub_a**\n";
print " sub_b **$sub_b**\n";
for $key (keys %sub_assoc)
{
print " sub_assoc - Key: $key Value: $sub_assoc{$key}\n";
}
print " sub_c **$sub_c**\n";
return;
}
When this code is executed by perl-v5.001 the following results are
obtained.
value passed #1 **a**
value passed #2 **b**
value passed #3 **two**
value passed #4 **22**
value passed #5 **one**
sub_a **a**
sub_b **b**
sub_assoc - Key: one Value: 11
sub_assoc - Key: two Value: 22
sub_c **c**
When the code is executed by perl-v5.005_03 the following incorrect results
are obtained.
value passed #1 **a**
value passed #2 **b**
value passed #3 **two**
value passed #4 **22**
value passed #5 **one**
sub_a **a**
sub_b **b**
sub_assoc - Key: one Value: 11
sub_assoc - Key: two Value: 22
sub_assoc - Key: c Value:
sub_c ****
As one can see, perl has a bug such that it does not find the end of the
associative array correctly in the subroutine.
Has anyone else seen this bug?
Does anyone know where I can obtain a buglist and patches for v5.005_03?
Does this bug exist in versions previous to v5.005_03?
Who do I notify that this bug exists?
Thanks for any help in advance!
------------------------------
Date: Mon, 7 Jun 1999 13:12:19 -0500
From: "Lee Pasquali" <pasquali@uthscsa.edu>
Subject: Possible compiler error when passing associative arrays
Message-Id: <7jh20l$dr0$1@cosmos.uthscsa.edu>
I am converting a perl cgi from perl-v5.001 to perl-v5.005_03. The cgi
contains code simular to that listed below.
local ($a, $b, $c, %assoc);
$a = "a";
$b = "b";
$c = "c";
$assoc{one} = "11";
$assoc{two} = "22";
&print_values($a, $b, %assoc, $c);
sub print_values
{
local($sub_a, $sub_b, %sub_assoc, $sub_c) = @_;
print " value passed #1 **$_[0]**\n";
print " value passed #2 **$_[1]**\n";
print " value passed #3 **$_[2]**\n";
print " value passed #4 **$_[3]**\n";
print " value passed #5 **$_[4]**\n";
print "\n\n";
print " sub_a **$sub_a**\n";
print " sub_b **$sub_b**\n";
for $key (keys %sub_assoc)
{
print " sub_assoc - Key: $key Value: $sub_assoc{$key}\n";
}
print " sub_c **$sub_c**\n";
return;
}
When this code is executed by perl-v5.001 the following results are
obtained.
value passed #1 **a**
value passed #2 **b**
value passed #3 **two**
value passed #4 **22**
value passed #5 **one**
sub_a **a**
sub_b **b**
sub_assoc - Key: one Value: 11
sub_assoc - Key: two Value: 22
sub_c **c**
When the code is executed by perl-v5.005_03 the following incorrect results
are obtained.
value passed #1 **a**
value passed #2 **b**
value passed #3 **two**
value passed #4 **22**
value passed #5 **one**
sub_a **a**
sub_b **b**
sub_assoc - Key: one Value: 11
sub_assoc - Key: two Value: 22
sub_assoc - Key: c Value:
sub_c ****
As one can see, perl has a bug such that it does not find the end of the
associative array correctly in the subroutine.
Has anyone else seen this bug?
Does anyone know where I can obtain a buglist and patches for v5.005_03?
Does this bug exist in versions previous to v5.005_03?
Who do I notify that this bug exists?
Thanks for any help in advance!
------------------------------
Date: Mon, 7 Jun 1999 11:54:24 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Possible compiler error when passing associative arrays
Message-Id: <MPG.11c5b53fcb4358d989b86@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7jh1oj$dqg$1@cosmos.uthscsa.edu> on Mon, 7 Jun 1999 13:07:59
-0500, Lee Pasquali <pasquali@uthscsa.edu> says...
...
> &print_values($a, $b, %assoc, $c);
>
> sub print_values
> {
> local($sub_a, $sub_b, %sub_assoc, $sub_c) = @_;
It is proper to use 'my' here, not 'local'.
...
> sub_a **a**
> sub_b **b**
> sub_assoc - Key: one Value: 11
> sub_assoc - Key: two Value: 22
> sub_assoc - Key: c Value:
> sub_c ****
>
>
> As one can see, perl has a bug such that it does not find the end of the
> associative array correctly in the subroutine.
There is no bug. I can't vouch for your results with perl 5.001, but
there would have been no bug there either.
The problem is 'cockpit error'. When you pass an aggregate (array or
hash) to a subroutine, it gets flattened into a list. When you then
assign that list inside the subroutine to an aggregate, *all* the
argument values from then on end up in the aggregate.
Look in perlsub for the section "Pass by Reference".
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 7 Jun 1999 17:09:18 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: Regular Expressions
Message-Id: <sin1ycvsxt.fsf@cre.canon.co.uk>
Andrea L. Spinelli <aspinelli@ismes.it> wrote:
> Or the first number after any non-digit characters
>
> /^\D*(\d+)/
Which is the same as
/(\d+)/
since Perl's regexp engine returns the leftmost match.
--
Gareth Rees
------------------------------
Date: Mon, 07 Jun 1999 17:48:21 GMT
From: dhosek@quixote.com
Subject: Signal/sleep hidden interaction?
Message-Id: <7jh0l2$tjf$1@nnrp1.deja.com>
I'm writing a simple daemon script which effectively has a loop along
the lines of
while ($ok) {
sleep 50;
ping_test(foo,10);
}
sub ping_test {
print STDERR "PING: $_[0]\n";
my $secs=$_[1];
$secs=1 if ($secs < 1);
my $responses;
# This code is adapted from some code that I found on usenet.
local $SIG{ALRM} = sub { die "Stopping ping ($_[0])"; };
eval {
open (PING, "ping -c 1 $_[0] |");
alarm $secs;
$responses=0;
while (<PING>) {
$responses++;
}
alarm 0;
};
close (PING);
# set the return code
my $rc=2;
$rc=0 if ($responses > 1);
# Print cell for test. Note use of main::DETAILS rather than
# DETAILS on the file selector
print main::DETAILS "<TD bgcolor=$color_code[$rc]>PING</TD>\n";
# return status code
return $rc;
}
There's more but this is essentially the key stuff. I also have a
handler in place to catch sighup which should restart the daemon, but it
seems that when the program's in sleep status, it doesn't hear the
sighup. What do I need to do to make this work?
-dh
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 07 Jun 1999 12:56:46 -0500
From: User <user@nowhere.com>
Subject: Syntax for square roots?
Message-Id: <375C07DE.4BA03F97@nowhere.com>
I have been trying to find if perl can take the square roots of
numbers. The "^" does not work if I try 2^0.5.
For that matter I can't square numbers either. If somebody knows
whether square roots and squaring can be done in Perl or not; or knows a
page for math functions let me know.
Thanks
Bence
bence@ecn.purdue.edu
------------------------------
Date: Mon, 7 Jun 1999 11:33:59 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Syntax for square roots?
Message-Id: <MPG.11c5b076278a031a989b84@nntp.hpl.hp.com>
In article <375C07DE.4BA03F97@nowhere.com> on Mon, 07 Jun 1999 12:56:46
-0500, User <user@nowhere.com> says...
> I have been trying to find if perl can take the square roots of
> numbers. The "^" does not work if I try 2^0.5.
> For that matter I can't square numbers either. If somebody knows
> whether square roots and squaring can be done in Perl or not; or knows a
> page for math functions let me know.
It would be rather useless to have a programming language in which one
couldn't square a number, for example -- wouldn't it?
`perldoc -f sqrt`
$n_squared = $n * $n;
There is also a power function, written using the exponentiation
operator ** (not the exclusive-or operator ^). But as it is general, it
would likely be less efficient than either of the above special-purpose
expressions.
As for math functions, do `perldoc perlfunc` and look for this near the
beginning:
Numeric functions
abs, atan2, cos, exp, hex, int, log, oct, rand, sin, sqrt, srand
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 07 Jun 1999 12:51:41 -0400
From: Greg Bartels <gbartels@xli.com>
Subject: Re: The artistic license and perl:
Message-Id: <375BF89D.233E100D@xli.com>
Russ Allbery wrote:
>
> Russ Allbery <rra@stanford.edu> writes:
>
> > I've mailed Bruce Perens, Russ Nelson, and sent another message to Eric
> > Raymond on the subject.
>
> The response of both Bruce Perens and Russ Nelson was that per-usage fees
> are not specifically ruled out in the OSD but that no license that had
> such a provision would be granted the certification mark, and that the OSD
> is a set of guidelines rather than a strict legal document.
right, the open source definition is a set of requirements that a
licence must meet if it is to qualify as open source.
The Artistic license, meets the open source definition, if I remember,
but people do have concerns with it.
can anyone explain the difference between the Artistic License and
the Library Gnu Public License? I'll do some digging tonight and
see if i can find anything.
Greg
> Which makes sense to me.
>
> --
> #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
> $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
> 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
> rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Mon, 07 Jun 1999 12:01:18 -0500
From: therzog@knotech.com (Tim Herzog)
Subject: unimplemented functions
Message-Id: <therzog-0706991201180001@therzog-host105.dsl.visi.com>
I just tried running a perl script that uses flock with Active Perl on a
Win98 box and got this message:
flock() unimplemented on this platform at foo.pl line 10.
ActiveState's support pages confirm that some built-in's aren't
implemented under Win95/98, notably flock.
Is there any way I can check for a built-in function's implementation
status prior to calling it?
Or is there a signal I can trap when an unimplemented built-in is called?
And barring all that, is there some global variable that I can use to
determine what OS *version* I'm running? I don't want to use any of the
Win32 modules unless I really have to, because this script is supposed to
run w/o platform modifications (i.e., has to run on Linux/Unix), and 'use'
works at compile time. I thought $Config{'osvers'} might help, but it
evaluates to "4.0" under Win98, so I don't think that's it.
Any help is appreciated.
--
Tim Herzog
------------------------------
Date: Mon, 07 Jun 1999 17:19:10 GMT
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: unimplemented functions
Message-Id: <7jguqk$s6c$1@monet.op.net>
In article <therzog-0706991201180001@therzog-host105.dsl.visi.com>,
Tim Herzog <therzog@knotech.com> wrote:
>Is there any way I can check for a built-in function's implementation
>status prior to calling it?
eval { flock STDIN, 0 };
$FLOCK_UNIMPLEMENTED = $@;
if ($FLOCK_UNIMPLEMENTED) {(do something else) } else { use flock}
>Or is there a signal I can trap when an unimplemented built-in is called?
That's what `eval' does. It executes the code that follows in braces,
and if the code causes a fatal exception, then instead of killing your
program it stores the exception into the special $@ variable.
>'use' works at compile time.
You can delay a `use' until run time like this:
require Module;
Module->import();
If you want to load the module at compile time, but conditionally, you
can do something like this:
BEGIN {
if (some condition) {
require Module;
Module->import();
}
}
Now the module is loaded at compile time, but only if the condition is true.
------------------------------
Date: 7 Jun 1999 17:37:17 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: unimplemented functions
Message-Id: <375C02BE.69C740B6@vpservices.com>
Tim Herzog wrote:
> ActiveState's support pages confirm that some built-in's aren't
> implemented under Win95/98, notably flock.
>
> Is there any way I can check for a built-in function's implementation
> status prior to calling it?
To test for flock:
use constant HAS_FLOCK => eval { flock STDOUT, 0; 1 };
...
if( HAS_FLOCK ) {...}
--
Jeff Zucker
jeff@vpservices.com
------------------------------
Date: 7 Jun 1999 17:20:35 GMT
From: elf@halcyon.com (Elf Sternberg)
Subject: Re: XS: Overriding errno?
Message-Id: <7jgv13$ac1$1@brokaw.wa.com>
In article <7j9l3j$8pd$1@news.NERO.NET>
Dan Sugalski <sugalskd@netserve.ous.edu> writes:
>Elf Sternberg <elf@halcyon.com> wrote:
>: I'd like to override the settings on errno so that I can set them
>: myself. Looking around inside the guts of mg.c, this doesn't seem
>: possible. Anyone get this to work?
>How much control over errno do you want? If you just want to set it
>occasionally in your XS code when an error happens, use the SETERRNO
>macro. It takes two integers--the first is set into errno/$!, while the
>second is stuck in $^E.
>
>If you actually want to take complete control, you might be able to get
>away with setting some magic on a generic scalar and then doing a
>
> *! = \$magic_scalar;
>
>but I'm not sure I'd count on that working.
I tried both and ended up going with a third option. *Grin*
I did, however, end up using the SvNOK_on() hack. That is *so* cool!
Elf
--
Elf M. Sternberg, rational romantic mystic cynical idealist
If you're so smart, why aren't you naked?
A.A 1493 http://www.halcyon.com/elf/
------------------------------
Date: 7 Jun 1999 18:29:46 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: XS: Overriding errno?
Message-Id: <7jh32q$f0s$1@news.NERO.NET>
Elf Sternberg <elf@halcyon.com> wrote:
: In article <7j9l3j$8pd$1@news.NERO.NET>
: Dan Sugalski <sugalskd@netserve.ous.edu> writes:
:>Elf Sternberg <elf@halcyon.com> wrote:
:>: I'd like to override the settings on errno so that I can set them
:>: myself. Looking around inside the guts of mg.c, this doesn't seem
:>: possible. Anyone get this to work?
:>How much control over errno do you want? If you just want to set it
:>occasionally in your XS code when an error happens, use the SETERRNO
:>macro. It takes two integers--the first is set into errno/$!, while the
:>second is stuck in $^E.
:>
:>If you actually want to take complete control, you might be able to get
:>away with setting some magic on a generic scalar and then doing a
:>
:> *! = \$magic_scalar;
:>
:>but I'm not sure I'd count on that working.
: I tried both and ended up going with a third option. *Grin*
: I did, however, end up using the SvNOK_on() hack. That is *so* cool!
Just out of curiosity, what was option #3? (And you're right, the Sv?OK_on
hacks are really cool. Sneaky and underhanded, but cool :)
Dan
------------------------------
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 5913
**************************************