[8592] in Perl-Users-Digest
Perl-Users Digest, Issue: 2209 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 30 13:07:34 1998
Date: Mon, 30 Mar 98 10:00:26 -0800
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, 30 Mar 1998 Volume: 8 Number: 2209
Today's topics:
"Unsupported function alarm function..."??? <cbrown@erols.com>
Re: (Q)Setuid and FindBin <jdf@pobox.com>
Re: Bitwise? (M.J.T. Guy)
free disk space <smubit1@gl.umbc.edu>
Help with serial communications under Linux (Rob Pinelli)
Re: how to assign unix command options in perl (M.J.T. Guy)
Re: Is there a "Newsgroup" for Newbies to Perl? <ljz@asfast.com>
Re: Is there a "Newsgroup" for Newbies to Perl? <johnc@interactive.ibm.com>
Re: Is there a function File:Diff available ? <tchrist@mox.perl.com>
Re: MacPerl fake 'exec'? (John Moreno)
Re: Need sorting routine in Perl (Stuart McDow)
Re: newbie question:how to embed perl in html <amar@iss-gmbh.de>
Re: OLE Automation with Excel Example Required <cee123@ibm.net>
Re: Perl not updating %INC after unsuccessful load. (M.J.T. Guy)
Re: Scalar Variable as an array name (M.J.T. Guy)
Re: Scalar Variable as an array name (M.J.T. Guy)
Re: Scalar Variable as an array name <tchrist@mox.perl.com>
SETUID to user from root. (Jason C. Hill)
Sneex having problems <gwynne@utkux.utk.edu>
Statistics for comp.lang.perl.misc <gbacon@cs.uah.edu>
Re: The "Y2k-bugs-are-not-just-a-legacy-problem" FAQ (Rodney Reid)
Re: The "Y2k-bugs-are-not-just-a-legacy-problem" FAQ <theranc@geocities.com>
Re: The "Y2k-bugs-are-not-just-a-legacy-problem" FAQ (Craig Berry)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 30 Mar 1998 11:42:20 -0500
From: Chris Brown <cbrown@erols.com>
Subject: "Unsupported function alarm function..."???
Message-Id: <351FCB6C.A02F55E5@erols.com>
I am getting the following message when using the 'pingecho' command
from the Net::Ping module:
"The Unsupported function alarm function is unimplemented at
C:\Perl\lib/Net/Ping.pm line 51, <CONFFILE> chunk 64."
I have tried Perl verision 5.004_02 and ActiveWare's port of Perl for
Win32 Build 316. Both versions produce the same error.
I'm just trying to determine if a machine is available from a perl
script before processing is attempted on that machine.
Any ideas?
Chris Brown (cbrown@erols.com)
------------------------------
Date: 30 Mar 1998 11:45:07 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: (Q)Setuid and FindBin
Message-Id: <emzkyvos.fsf@mailhost.panix.com>
Thank you for your excellent answers, and for sparing the rod re my
not having r'd tfm.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: 30 Mar 1998 17:31:06 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Bitwise?
Message-Id: <6foksq$ft0$1@lyra.csx.cam.ac.uk>
In article <3512e0db.12537344@nntp2.ba.best.com>, <rfonline@nbn.com> wrote:
>Greetings,
>
>I have a set of "items," which are represented by a series of 0s and
>1s. For example, an item might look like this:
>
>10011
>
>Each 0 or 1 stands for either yes or no on a series of
>characteristics.
>
>I am comparing the items to see how "alike" they are, that is, how
>many characteristics they have in common. For example:
>
>10011
>00000
>
>The above two items have two characteristics in common (the second and
>third).
>
>I'm currently making my comparison with a for loop, which works just
>fine. What I'm thinking, though, is that there must be some way, with
>perl's bitwise operators, to make the comparison much more efficiently
>-- or at least more elegantly! I'm not really a programmer (perl is
>my first language), and I'm not very familliar with sophisticated
>bitwise idioms, so I'm kind of in the dark here.
$n = ($temp = $x^$y) =~ tr/\0//;
Mike Guy
------------------------------
Date: Mon, 30 Mar 1998 12:06:25 -0500
From: Stephen Mubita <smubit1@gl.umbc.edu>
Subject: free disk space
Message-Id: <Pine.SGI.3.96.980330120535.13149A-100000@jig.gl.umbc.edu>
Dumb question, I fear. How can a perl script discover how much disk space
is free on a drive / filesystem ?
Thank you,
Stephen
Stephen Mubita smubit1@umbc.edu
======================================================================
'God opposes the proud, but gives grace to the humble.'
James 3 : 6b
----------------------------------------------------------------------
| UCS is not responsible for any opinions contained here |
====================******************************====================
------------------------------
Date: 30 Mar 1998 16:25:52 GMT
From: rpinelli@bnr.ca (Rob Pinelli)
Subject: Help with serial communications under Linux
Message-Id: <6foh2g$qhh@brtph500.bnr.ca>
Hello,
I'm currently working on writing a Perl application that
interfaces with a simple serial device (a weather computer)
to collect, format, and output data. I've been having some
problems with the communications aspect of it.
Basically, I can read data from the serial port using
sysread() as long as data is there. However, if there are
no characters waiting on the filehandle, the sysread() call
hangs. To communicate with the weather computer, I need to
send a series of space characters to it until it responds
with a message that it has cleared its buffers. I cannot
seem to do this because if I send a space and then try to
read the serial port, the app hangs unless the device
sends something back (which it doesn't do until reporting
that the input buffers have been cleared).
Is there a way to specify a timeout for reads? I would
like the sysread to try for, say, 1 second before giving
up and sending another space. Once the message is received
that the buffers have cleared, I can begin synchronous
communication where I send commands and can rely on the
appropriate response from the device. Perhaps sysopen()
or ioctl() would help me in polling the serial port via
read timeouts?
On a related note... I am not sure how to configure the
serial port from within my program. I have to use minicom
to set the baud rate and parity, etc., and then quit without
resetting before running my program. What is the common way
of setting baud, parity, etc. for the serial port in Perl?
I have tried system("stty 2400 > /dev/cua0"); but
it doesn't seem to affect the baud rate. Is this another
sysopen() functionality? stty? ioctl? vec? select? I'm
rather lost here =(...
Any help appreciated, please email or post here!
--Rob
p.s. I did see in one of the FAQs how to tell if a character
is waiting on a filehandle. I do not know if this works for
character devices (/dev/cua0) but if all else fails I could
try it. I would really prefer the sysread() to timeout if no
characters are waiting.
--
Rob Pinelli rpinelli@nortel.ca | I do not speak for my
Dept. 3Z31 ISDN Display Services | employer. However, the
NORTEL, Inc. (919) 991-8940 | opinions expressed here may
Research Triangle Park, NC 27709 | be bought for a nominal fee.
------------------------------
Date: 30 Mar 1998 17:24:41 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: how to assign unix command options in perl
Message-Id: <6fokgp$fq9$1@lyra.csx.cam.ac.uk>
Martin Vorlaender <MARTIN@RADIOGAGA.HARZ.DE> wrote:
>Lalit Jairath (ljairath@wright.aps.uoguelph.ca) wrote:
>: Hi all,
>
>: how can i assign unix command options in perl?
>
>: i do the following:
>
>: $_ = `date -u +%B`;
>: print;
>
>: it does not work. it just prints B.
>
>Backticks interpolate, so in the above command, %B gets interpreted as "the
>hash named B".
Nonsense. Have you ever tried it? Only $xxx and @xxx interpolate,
whether in qq(), qx() or regexen.
Mike Guy
------------------------------
Date: 30 Mar 1998 10:59:53 -0500
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <luemzkdv9i.fsf@asfast.com>
cberry@cinenet.net (Craig Berry) writes:
> James Hurd (jhurd@ucs.indiana.edu) wrote:
> : Then is is impossible for a non-programmer to use Perl,
> : so this debate is actually as ridiculous as it initally appears.
>
> It is impossible for a non-programmer to use Perl in the same sense that
> it is impossible for a teetotaller to drink a Martini; either action
> removes one from the corresponding category.
>
> However, I think what's being suggested is that, to make *effective* use
> of Perl (or any other programming language), there is a certain mental
> attitude and behavioral approach which will lead one toward being a *good*
> programmer. Such things as compulsively reading all available docs,
> performing simple experiments to isolate poorly understood language
> elements, and extending professional courtesy to fellow programmers all
> compound to make one a better programmer.
Well, these are all qualities that some of the more accomplished
regular contributors here in comp.lang.perl.misc often request of
other posters to this newsgroup, but I don't consider all of these to
be intrinsic qualities of a "good" programmer. These behaviors might
certainly be considered good netiquette, however.
It's true that many experienced programmers I know will jump in and
try things before researching them, and this comes close to the
"simple experiments" mentioned above. However, how many experienced
programmers do you know of who read all available docs? How many
would laugh in your face if you tried to make this a "compulsory"
practice? Many of us programmers read the docs as a last resort,
after we have tried hacking our way through a problem with no positive
results.
As for professional courtesy, I think that its absence or presence
have nothing to with being a good programmer or a bad programmer.
Some good programmers are courteous, others are not. Some bad
programmers are courteous, others are not. In my experience, the
place where person stands on the courtesy spectrum and the place where
he or she stands on the programming-ability spectrum are completely
uncorrelated.
Some of the more experienced (in Perl), respected, and prolific
posters in comp.lang.perl.misc are often extremely discourteous.
Certain of these posters often behave like arrogant, immature twits
who seem to go out of their ways to make condescending statements to
people who ask naive questions here. My impression is that when these
naive posters are asked to be "courteous", they are often really being
asked to be obsequious in response to some experienced Perl user's
childish, arrogant pronouncements.
> A person who posts a FAQ, clearly without having done ten minutes of
> research on the topic, is violating at least two and usually three
> of the precepts above. And that's what causes the gurus to heap
> scorn on such a person. Why should they respect someone who doesn't
> want to become a good programmer, but instead expects others to do
> the hard work?
What you are talking about here is netiquette, not good programming
practice. It is true that inexperienced net users will often not go
to the FAQ list before asking questions here, and I do understand the
frustration that many long-time contributors to comp.lang.perl.misc
feel at having the same questions asked over and over by people who
seem to have no clue about what is going here.
However, in my opinion, few of these people are expecting others to do
hard work, and there is not one of them who is not worthy of common
human respect.
In my opinion, there is a respectful, courteous way to reply to people
who are posing frequently asked questions, and there is a polite,
respectful, considerate way to let someone know that their answer
already appears in a FAQ list. In my opinion, the arrogant,
condescending replies that some people here seem to almost gleefully
make in response to these posters are totally uncalled for.
--
Lloyd Zusman
ljz@asfast.com
------------------------------
Date: Mon, 30 Mar 1998 11:34:23 +0000
From: John Call <johnc@interactive.ibm.com>
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <351F8338.8076DBFD@interactive.ibm.com>
> In my opinion, there is a respectful, courteous way to reply to people
> who are posing frequently asked questions, and there is a polite,
> respectful, considerate way to let someone know that their answer
> already appears in a FAQ list. In my opinion, the arrogant,
> condescending replies that some people here seem to almost gleefully
> make in response to these posters are totally uncalled for.
>
> --
> Lloyd Zusman
> ljz@asfast.com
I've been waiting on this to happen for a long time.
I have to say that I am glad Mr. Zusman and others like him are finally
requesting and expecting a little courtesy from some of the 'experts' on this
list.
I will be the first to agree that many questions that are asked here are
answered in the FAQ. What I have never understood is why the 'experts' use so
much bandwith and time to flame someone when all they have to do is say 'look
in the FAQ' or say nothing at all. I would rather they don't post an answer to
the simple questions if it is going to cause so much trouble.
I am a programmer by trade. It is what I do. I expect more out of myself than I
do out of someone who is not a programmer. Many people on this list are not as
net savvy as others and may not be completely familiar with www.perl.com or
with CPAN. To be honest, CPAN can be a difficult place for me to find things
sometimes and I go there more often than a lot of "newbies".
Anybody who has participated in a sport knows what I am about to say is very
true. This list has a very "locker room" attitude about it. There are the jocks
(experts) and the freshmen (newbies). The jocks take a lot of pride in there
ability, which they should. I am very impressed and humbled by the amount of
knowledge on this list, it far surpasses my own. However, when pride grows so
large to be just pure ego then no one is impressed anymore.
Perl is supposed to be a language for everybody, that is why it is free. The
Perl community has a reputation as being open to everyone, that is one reason
for this list. If the Perl community wants to keep that reputation then I
recommend a little more understanding when it comes to 'newbies'.
--
John Call
------------------------------
Date: 30 Mar 1998 16:18:51 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Is there a function File:Diff available ?
Message-Id: <6foglb$dsl$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, "Burkhard Kiesel" <burkhard.kiesel@med.siemens.de> writes:
:is there a Module called File:Diff available, where you get out the
:difference between two files,
:like the "unix diff command" ??
Install Unix? How long must you torture yourself, or recreate the wheel?
Microsoft is its own punishment.
Really, if you want a programmer friendly environment, you need
some basic tools installed. Following is a section of my Basic Unix
Knowledge checklist. You need to find the first two sets, or install
a real system. Microsoft was designed for things entirely antithetical
to what a programmer is trying to do.
--tom
3. Basic commands
Here are essential Unix commands that everyone should be able to use.
They should probably know a the most common switches on each, too,
like grep -i, jobs -l, cat -v, and cp -r. (Yes, I know some are
built-ins):
+----------------------------------------------------------------+
| cat, cd, chmod, cp, date, echo, env or printenv, exit, grep, |
| ftp, jobs and fg and bg, kill, lpr and lpq and lprm, ls, mail, |
| man, mkdir, more or less, mv, passwd, ps, pwd, rm, rmdir, sh, |
| stty, telnet, umask, and wc. |
+----------------------------------------------------------------+
If they can't use these, they're going to be somewhere between
moderately and severely unhappy. Perhaps that list should be
enumerated as part of the "basic Unix commands knowledge" pre-req.
They really need to know how to unpack foo.tar.gz archives, too,
and mail back complete directories via
shar -z dir1 dir2 | Mail -s 'here you go' user@host.dom
and sh when it gets there.
They should also be able to use their windowing system if they have
one, probably xterm under some random window mangler. And at some
point early, they will probably also pick up:
last, who or w, write or talk, and finger. maybe lynx.
Here are other commands that I'd expect experienced Unix users to
be familar with:
+---------------------------------------------------------------+
| alias, at, awk, basename, crontab, cu or dip or tip, dirname, |
| df, diff, du, egrep, find, gzip, hostname, id, ln, locate, |
| netstat, od, sed, shar, sort, strings, tee, time, touch, tr, |
| tty, and uname. |
+---------------------------------------------------------------+
C developers should probably know
+---------------------------------------------------------------+
| as, cc or gcc or c++ or g++, gdb or sdb or dbx, ld, ldd, lex, |
| make, nm, and yacc. |
+---------------------------------------------------------------+
Sysadmins should probably know need to know a bunch more.
+-----------------------------------------------------------------+
| MAKEDEV, arp, chgrp, chown, chsh etc, ci and co and rcs, cpio, |
| cron, dd, domainname, dump, etherfind, fsck, host, ifconfig, |
| in.(various daemons)d, inetd, init, lpc, lsof, mailq, mount |
| and umount, mt, newaliases, nfsd, nslookup, ping, quot, quota |
| programs, rc scripts, rcp and rsh and rlogin, rdist, restore, |
| route, scp and ssh and slogin, sendmail, showmount, su, tar, |
| top, traceroute, truss or trace or strace, vipw, vmstat and any |
| other *stat, wall and rwall, yp stuff, shutdown, |
+-----------------------------------------------------------------+
And someone other than me should know these :-)
+--------------------------------------------+
| troff, tbl, eqn, pic, refer and bib tools. |
+--------------------------------------------+
--
Tom Christiansen tchrist@jhereg.perl.com
"Just because you're into control doesn't mean you're in control."
--Larry Wall
------------------------------
Date: Mon, 30 Mar 1998 16:33:34 GMT
From: phenix@interpath.com (John Moreno)
Subject: Re: MacPerl fake 'exec'?
Message-Id: <1d6pc1g.1cuw7va10t09c8N@roxboro0-001.dyn.interpath.net>
Greg Dunn <gregdunn@indy.net> wrote:
> I've scoured the sample scripts and documents, but I'm unable to find a
> suggested way to launch a Mac application from MacPerl; even the Apple
> event docs aren't very helpful. I don't want to run an AppleScript (I'm
> replacing a couple of AppleScripts with a Perl script already!) and it's OK
> if the Perl script goes away when the subsequent app launches.
>
> Can anyone point me to a source of examples, or a place in the docs where I
> can read more about this?
Process.pm and LaunchApplication
--
John Moreno
I am trying to convince the author of YA-NewsWatcher that the latest
version should be released to the public. He doesn't think there's much
interest in a new version. Help me prove him wrong. To do so, send me
mail <mailto:phenix@interpath.com> with a Subject of New YA. Comments
on what you like/dislike in the current version will be appreciated.
------------------------------
Date: 30 Mar 1998 16:47:26 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: Need sorting routine in Perl
Message-Id: <6foiau$ll2$1@ns1.arlut.utexas.edu>
gebis@albrecht.ecn.purdue.edu (Michael J Gebis) writes:
> smcdow@arlut.utexas.edu (Stuart McDow) writes:
>
> }gebis@albrecht.ecn.purdue.edu (Michael J Gebis) writes:
> }>
> }> sub fast_sort {
>
> } sort { $a <=> $b } @_;
> You really didn't even try my program, did you?
Just tried it. Now, you try it. Here's the code that I ran:
#!/usr/bin/perl
use Benchmark;
sub is_sorted {
my($x,@list)=@_;
my($e);
if($#list==-1){return 1;}
foreach $e (@list) {
if($e>=$x) {
$x=$e;
} else {
return 0;
}
}
return 1;
}
sub fast_sort {
my(@list)=@_;
my($left,$right);
while(!is_sorted(@list)) {
# print "list: ",join(" ",@list),"\n";
$left=rand($#list+1);
$right=rand($#list+1);
if($right>$left){ #XXX
if($list[$left]>$list[$right]) { #XXX
($list[$right],$list[$left])=($list[$left],$list[$right]);
}
}
}
return @list;
}
sub p_sort {
sort { $a <=> $b } @_;
}
@list=(10,9,8,7,1,2,3,4,800,123,234,987,3.14159,223,-9,9,1,8,2,7.3,6,4,5.5,4.6,3.7,2.8,1.9);
timethese(1000,
{
'fast_sort' => 'fast_sort(@list)',
'p_sort' => 'p_sort(@list)',
}
);
# end of code
Here's the output that I got:
Benchmark: timing 1000 iterations of fast_sort, p_sort...
fast_sort: 433 secs (410.22 usr 0.02 sys = 410.24 cpu)
p_sort: 0 secs ( 0.01 usr 0.00 sys = 0.01 cpu)
(warning: too few iterations for a reliable count)
Hmmm, 433 seconds versus 0 seconds. I wonder which sort routine is
faster?
> I mean, come on,your sort doesn't even use "rand" anywhere. Please.
Perl's sort is implemented via the qsort(3) call. qsort() implements
the quick-sort algorithm, so perl's sort() and my version of
fast_sort() does indeed use random numbers.
Maybe you wrote your sort routine for fun and education, but for
performance considerations, it'll be hard to beat perl's built-in
sort(). I would be interested to see your sort routine written as an
XSUB.
Regards,
--
Stuart McDow Applied Research Laboratories
smcdow@arlut.utexas.edu The University of Texas at Austin
"It is obvious that about 750,000 people ago, Austin was a wonderful City."
------------------------------
Date: Mon, 30 Mar 1998 13:04:46 +0200
From: Amar Subramanian <amar@iss-gmbh.de>
Subject: Re: newbie question:how to embed perl in html
Message-Id: <351F7C4E.726F@iss-gmbh.de>
> Question: How do i call this script from a html page?
>
cp script.pl <www-home>/cgi-bin ;-)
and make sure the UID of the www server has the permission to execute
it, and you must use the -T switch.....for security reasons ;-)
regards amar
------------------------------
Date: Mon, 30 Mar 1998 11:37:50 -0500
From: Charles Engelke <cee123@ibm.net>
Subject: Re: OLE Automation with Excel Example Required
Message-Id: <351FCA5E.29A2@ibm.net>
Graeme Hutcheon wrote:
> I would like to create a grep type function for excel.
> I have a directory with a number of .XLS files and would like to
> retrieve indivial matching records from them and print them out.
>[text omitted]
> Could some kind person either post or send me an example of
> excel ole automation to send me
Here's some code that works for me. It opens a spreadsheet, reads a few
values from cells, and prints them to output. It's useless, but has all
the pieces needed to do what you want.
# Perl for ActiveState Win32 version; code begins below
my ($XLFile) = "c:\\Temp\\demo.xls";
use OLE;
$Excel = CreateObject OLE "Excel.Application"
or die "Couldn't run Excel\n";
$Excel->{'Visible'} = 1; # So you can see it, not needed otherwise
$Workbook = $Excel->Workbooks->Open ($XLFile);
$ItemNumber = $Excel->Range("c4")->{'Value'};
$StartDate = $Excel->Range("c5")->{'Value'};
$EndDate = $Excel->Range("c6")->{'Value'};
print "Item: $ItemNumber begins on $StartDate, and ends on $EndDate\n";
Charlie
------------------------------
Date: 30 Mar 1998 17:18:36 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Perl not updating %INC after unsuccessful load.
Message-Id: <6fok5c$fil$1@lyra.csx.cam.ac.uk>
Diego Zamboni <zamboni@cs.purdue.edu> wrote:
>In one of my programs, I'm doing something like this:
>
> eval "require $classpath; import $class";
( Not relevant to the main point, but (as always) eval EXPR isn't
the right thing to use there. Better is
eval { require $classpath; import $class };
)
>Which works ok most of the time. Context for my problem is: under some
>circumstances, the $classpath file will be present, but a file loaded
>by it will not be. I am handling the case adequately, then fetching
>the missing file, and executing the above again.
>
>The problem is that when the initial require for $classpath fails, Perl
>updates %INC nonetheless. Then, after I get the missing file, when I
>do the require for $classpath again, Perl consults %INC and decides not
>to read the file again.
>
>I am currently dealing with the problem by manually deleting the
>corresponding %INC entry when the load fails. However, I think that
>Perl should do that automatically.
>
>Is this a known problem?
Well, it's a known _feature_. %INC caches failures as well as successes.
When a require has failed, there's liable to be lots of other junk left
lying around, like subroutines that have already been defined before
the point of failure or symbol table entries. Clearing out all this
mess is in general very difficult if not impossible. (There can also
be memory leaks in this circumstance.)
So it's basically better to set about your problem in a different way.
Either
Arrange to check and load any prerequisites _before_ requiring $classpath.
or
Reorganise the code in $classpath so it does its own error recovery.
( I assume you have some knowledge and/or control over what is in
$classpath. If not, the opportunities for malevolent people are
endless. )
Mike Guy
------------------------------
Date: 30 Mar 1998 16:24:59 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Scalar Variable as an array name
Message-Id: <6foh0r$dv3$1@lyra.csx.cam.ac.uk>
Raj Ponnuraj <ponnuraj@yahoo.com> wrote:
>Mitch Lyman wrote:
>> I'm performing a push command.
>>
>> push(@{$var},$temp);
>>
>> $temp has a string with a value of 'P is a good tool which has improved'.
>> $var has a string name of 'Question2_Comments'.
>> But @{$var} is empty when i push the string on the array. I want push onto
>> the array with the end result being
>>
>> @Question2_Comments = (Patchit is a good tool which has improved);
>>
>> How do I do this using variables?
>
>If this is what you want to do, one way is to use eval, because you are trying
>
>to create a variable at run time... (if I understand it right).
No - you don't need and shouldn't use eval EXPR for this. To create
variables at run time, just use a symbolic reference, as Mitch is doing.
See perldoc perlvar.
Mike Guy
------------------------------
Date: 30 Mar 1998 16:42:16 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Scalar Variable as an array name
Message-Id: <6foi18$egl$1@lyra.csx.cam.ac.uk>
Keywords: Scalar Variable Array Name Perl
In article <6fo8ba$j9b@bcrkh13.bnr.ca>, Mitch Lyman <ingrjml@bnr.ca> wrote:
>I'm performing a push command.
>
>push(@{$var},$temp);
>
>$temp has a string with a value of 'P is a good tool which has improved'.
>$var has a string name of 'Question2_Comments'.
>But @{$var} is empty when i push the string on the array. I want push onto
>the array with the end result being
>
>@Question2_Comments = (Patchit is a good tool which has improved);
>
>How do I do this using variables?
>
>Below is the debug output
>
>
>main::(test:28): push(@{$var},$temp);
> DB<2> x $temp
>0 "P is a good tool which has improved"
> DB<3> x @{$var}
> empty array
> DB<4> x $var
>0 'Question2_Comments'
> DB<5> s
>main::(test:25): $temp = $hash{$var};
> DB<5> x @{$var}
> empty array
>
>
>Why will this syntax not work? According to my understanding of
>the documentation this should work.
That syntax is perfectly OK. (I'm not overly keen on symbolic references,
but that's another story.)
Without seeing more of your script, it's difficult to tell what's
happening, but I'll make a guess.
Note those line numbers (test:28) and (test:25). They aren't
consecutive. So the debugger's done more than just obeyed that one
statement. I'd guess that the statement is the last in a loop, and
it has wrapped round to the start of the loop. Now if $var is declared
my (or local) within the loop, it'll have reverted to some different
value, perhaps undef.
It would be worth printing out the values of $var and of
@Question2_Comments after the "s".
Mike Guy
------------------------------
Date: 30 Mar 1998 16:31:53 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Scalar Variable as an array name
Message-Id: <6fohdp$dsl$3@csnews.cs.colorado.edu>
Keywords: Scalar Variable Array Name Perl
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, ingrjml@bnr.ca (Mitch Lyman) writes:
:push(@{$var},$temp);
I sure wish I understood why people didn't use hard references
instead of this kludgey eval or symref stuff.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
The X server has to be the biggest program I've ever seen that doesn't
do anything for you. --Ken Thompson
------------------------------
Date: Mon, 30 Mar 1998 11:09:17 -0500
From: jhill@mitre.org (Jason C. Hill)
Subject: SETUID to user from root.
Message-Id: <jhill-3003981109320001@jhill-mac.mitre.org>
I have a perl script which is run as root, but on a couple of occassions I
need to set the UID to something other than 0. I've tried a couple of
things but failed on each one. I can't find any decent documentation on
this. Anyone have a quick and easy way of doing this? Thanks.
-Jason C. Hill
jhill@mitre.org
------------------------------
Date: Mon, 30 Mar 1998 11:23:20 -0500
From: "Bob Gwynne" <gwynne@utkux.utk.edu>
Subject: Sneex having problems
Message-Id: <6fogve$6po$1@gaia.ns.utk.edu>
I received the following from Sneex:
Please do me a big favor - my home system died Saturday night (was
playing with the new Intel R3 version of the BeOS) and I have been
unable to respond to people. Please post a note to c.l.p.m. stating
such for me (I don't have very good access from work.)
Please tell them I should be back online tomorrow and that I have
only received three responses and that management here does not
appear too supportive. but where there is a will there will be
a way...
Thx,
Sneex :-)
------------------------------
Date: 30 Mar 1998 17:31:23 GMT
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: Statistics for comp.lang.perl.misc
Message-Id: <6foktb$q7m$5@info.uah.edu>
Following is a summary of articles spanning a 7 day period,
beginning at 23 Mar 1998 17:27:20 GMT and ending at
30 Mar 1998 07:28:32 GMT.
Notes
=====
- A line in the body of a post is considered to be original if it
does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
- All text after the last cut line (/^-- $/) in the body is
considered to be the author's signature.
- The scanner prefers the Reply-To: header over the From: header
in determining the "real" e-mail address and name.
- Original Content Rating (OCR) is the ratio of the original content
volume to the total body volume.
- Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
Excluded Posters
================
perlfaq-suggestions\@mox\.perl\.com
Totals
======
Posters: 515
Articles: 1179 (492 with cutlined signatures)
Threads: 373
Volume generated: 1933.7 kb
- headers: 824.5 kb (16,453 lines)
- bodies: 1022.7 kb (31,334 lines)
- original: 713.0 kb (23,276 lines)
- signatures: 85.4 kb (1,726 lines)
Original Content Rating: 0.697
Averages
========
Posts per poster: 2.3
median: 1 post
mode: 1 post - 332 posters
s: 3.8 posts
Posts per thread: 3.2
median: 2 posts
mode: 1 post - 124 threads
s: 3.8 posts
Message size: 1679.5 bytes
- header: 716.1 bytes (14.0 lines)
- body: 888.3 bytes (26.6 lines)
- original: 619.3 bytes (19.7 lines)
- signature: 74.1 bytes (1.5 lines)
Top 10 Posters by Number of Posts
=================================
(kb) (kb) (kb) (kb)
Posts Volume ( hdr/ body/ orig) Address
----- -------------------------- -------
33 42.9 ( 22.5/ 20.0/ 11.0) jgloudon@bbn.com
32 43.0 ( 28.5/ 14.5/ 6.3) bill@astro.fccj.cc.fl.us
30 53.3 ( 22.7/ 22.6/ 12.7) rjk@coos.dartmouth.edu
27 38.8 ( 13.3/ 25.1/ 18.9) aml@world.std.com (Andrew M. Langmead)
24 37.1 ( 19.5/ 14.8/ 9.2) Tom Phoenix <rootbeer@teleport.com>
21 45.7 ( 18.8/ 22.2/ 17.0) comdog@computerdog.com (brian d foy)
21 41.1 ( 14.9/ 25.5/ 19.0) Zenin <zenin@archive.rhps.org>
16 28.0 ( 9.4/ 13.6/ 8.2) mike@stok.co.uk (Mike Stok)
15 27.5 ( 12.6/ 12.6/ 5.6) abigail@fnx.com
13 17.3 ( 8.7/ 8.5/ 4.4) jdporter@min.net
These posters accounted for 19.7% of all articles.
Top 10 Posters by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Address
-------------------------- ----- -------
53.3 ( 22.7/ 22.6/ 12.7) 30 rjk@coos.dartmouth.edu
45.7 ( 18.8/ 22.2/ 17.0) 21 comdog@computerdog.com (brian d foy)
43.0 ( 28.5/ 14.5/ 6.3) 32 bill@astro.fccj.cc.fl.us
42.9 ( 22.5/ 20.0/ 11.0) 33 jgloudon@bbn.com
41.1 ( 14.9/ 25.5/ 19.0) 21 Zenin <zenin@archive.rhps.org>
38.8 ( 13.3/ 25.1/ 18.9) 27 aml@world.std.com (Andrew M. Langmead)
37.1 ( 19.5/ 14.8/ 9.2) 24 Tom Phoenix <rootbeer@teleport.com>
28.0 ( 9.4/ 13.6/ 8.2) 16 mike@stok.co.uk (Mike Stok)
27.5 ( 12.6/ 12.6/ 5.6) 15 abigail@fnx.com
24.6 ( 8.1/ 16.5/ 12.3) 10 lassehp@imv.aau.dk (Lasse =?ISO-8859-1?Q?Hiller=F8e?= Petersen)
These posters accounted for 19.8% of the total volume.
Top 10 Posters by OCR (minimum of five posts)
==============================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.995 ( 5.5 / 5.5) 5 fl_aggie@thepentagon.com (I R A Aggie)
0.885 ( 8.5 / 9.7) 11 tchrist@mox.perl.com (Tom Christiansen)
0.797 ( 3.3 / 4.2) 7 smcdow@arlut.utexas.edu (Stuart McDow)
0.773 ( 10.0 / 13.0) 10 "Peter Perchansky" <fp@pmpcs.com>
0.766 ( 17.0 / 22.2) 21 comdog@computerdog.com (brian d foy)
0.763 ( 6.4 / 8.4) 5 doswald@xmission.com
0.753 ( 18.9 / 25.1) 27 aml@world.std.com (Andrew M. Langmead)
0.747 ( 12.3 / 16.5) 10 lassehp@imv.aau.dk (Lasse =?ISO-8859-1?Q?Hiller=F8e?= Petersen)
0.745 ( 1.8 / 2.4) 5 nvp@shore.net (Nathan V. Patwardhan)
0.744 ( 19.0 / 25.5) 21 Zenin <zenin@archive.rhps.org>
Bottom 10 Posters by OCR (minimum of five posts)
=================================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.448 ( 5.6 / 12.6) 15 abigail@fnx.com
0.433 ( 6.3 / 14.5) 32 bill@astro.fccj.cc.fl.us
0.415 ( 1.5 / 3.5) 6 Bob Trieger <sowmaster@juicepigs.com>
0.404 ( 1.7 / 4.2) 5 Birgitt Funk <birgitt@order.booktraders.com>
0.366 ( 1.4 / 3.8) 6 keithmur@mindspring.com
0.347 ( 1.5 / 4.2) 5 Jan Krynicky <jkry3025@comenius.ms.mff.cuni.cz>
0.314 ( 1.5 / 4.6) 5 fscholz@wv.mentorg.com
0.226 ( 0.8 / 3.5) 5 Aaron R Kulkis <akulkis@be1151.pd3.ford.com>
0.196 ( 0.4 / 2.0) 5 kpreid@ibm.net (Kevin Reid)
0.193 ( 1.9 / 9.8) 8 Benjamin Holzman <bholzman@earthlink.net>
Top 10 Threads by Number of Posts
=================================
Posts Subject
----- -------
36 PROPOSAL: The Perl Dictionary
34 Going Rates for PERL Programming???
24 What does "UNIX" stand for..
20 Is there a "Newsgroup" for Newbies to Perl?
19 Copy file command.
17 verifying email address -- how?
15 What does this one liner do?
13 Odd-Numbered Array to Hash
12 Need sorting routine in Perl
12 need regexp help
These threads accounted for 17.1% of all articles.
Top 10 Threads by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Subject
-------------------------- ----- -------
56.0 ( 29.0/ 22.3/ 12.9) 36 PROPOSAL: The Perl Dictionary
55.2 ( 25.7/ 27.5/ 17.3) 34 Going Rates for PERL Programming???
47.6 ( 16.3/ 28.5/ 15.8) 20 Is there a "Newsgroup" for Newbies to Perl?
45.3 ( 30.9/ 11.8/ 4.7) 24 What does "UNIX" stand for..
33.7 ( 14.3/ 17.9/ 13.4) 19 Copy file command.
28.1 ( 12.4/ 14.0/ 8.8) 17 verifying email address -- how?
28.0 ( 11.3/ 15.1/ 10.1) 15 What does this one liner do?
26.5 ( 7.3/ 19.1/ 12.2) 9 Perl versus Python benchmark-results
21.4 ( 9.2/ 11.0/ 6.1) 13 Odd-Numbered Array to Hash
20.8 ( 3.5/ 17.3/ 7.8) 5 - Perl Script to Find & Display Matches.. -
These threads accounted for 18.7% of the total volume.
Top 10 Threads by OCR (minimum of five posts)
==============================================
(kb) (kb)
OCR orig / body Posts Subject
----- -------------- ----- -------
0.853 ( 2.7/ 3.2) 5 How to log input to different files in perl
0.835 ( 3.6/ 4.3) 5 Perl on Win95 - CMD32 - File Length Restriction ?
0.821 ( 9.9/ 12.1) 6 Using perl code as a config file syntax? (Or, can require return more then one value?)
0.812 ( 1.9/ 2.4) 7 What does this mean =~ ?
0.794 ( 4.3/ 5.4) 5 Please help with ACGI vs. CGI in MacPerl
0.786 ( 5.0/ 6.4) 5 SMTP
0.777 ( 7.5/ 9.7) 10 Sysadmin struggeling with PERL/Sed and etc...
0.769 ( 5.3/ 6.9) 8 trivial example reveals a taint problem?
0.764 ( 5.9/ 7.7) 6 || and 'or' - implications?
0.762 ( 2.4/ 3.2) 5 Forced log out after a defined total time, how?
Bottom 10 Threads by OCR (minimum of five posts)
=================================================
(kb) (kb)
OCR orig / body Posts Subject
----- -------------- ----- -------
0.551 ( 1.5 / 2.7) 5 Interpolating into a variable? How to?
0.547 ( 4.8 / 8.7) 6 "Newbie" Crib Notes
0.531 ( 3.3 / 6.2) 6 NNTP and Perl
0.522 ( 3.5 / 6.7) 5 Challenge your programming skill
0.510 ( 2.7 / 5.4) 8 Days of the Week
0.506 ( 1.2 / 2.4) 5 crypt paranoia ?
0.454 ( 7.8 / 17.3) 5 - Perl Script to Find & Display Matches.. -
0.450 ( 1.5 / 3.4) 6 help with Hardware ethernet addresses please
0.401 ( 4.7 / 11.8) 24 What does "UNIX" stand for..
0.382 ( 1.7 / 4.6) 6 - Limiting the length of a list on a page..... -
Top 10 Targets for Crossposts
=============================
Articles Newsgroup
-------- ---------
35 comp.lang.perl.modules
27 comp.object
24 comp.os.linux.advocacy
24 comp.lang.c++
24 comp.unix.advocacy
23 comp.lang.javascript
21 comp.lang.tcl
19 comp.os.ms-windows.advocacy
18 comp.sys.amiga.advocacy
18 comp.infosystems.www.advocacy
Top 10 Crossposters
===================
Articles Address
-------- -------
43 Aaron R Kulkis <akulkis@be1151.pd3.ford.com>
22 dcorn@pdq.net (dc)
16 SofTec <softecusa@usa.net>
12 Felix Kogan <koganfe@cucis.cis.columbia.edu>
12 x-mdm30@amdahl.com-x (Mike Morrow says remove the x- & -x for a valid email address)
12 tplesco@FASTLLC.NET
12 bill@bilver.magicnet.net.REMOVETHIS (Bill Vermillion)
11 Dave.Riches@nt.com
11 mleese@unb.ca
11 "Clayton L. Scott" <tex@lager.engsoc.carleton.ca>
------------------------------
Date: 30 Mar 1998 10:10:52 -0600
From: rreid@earth.execpc.com (Rodney Reid)
Subject: Re: The "Y2k-bugs-are-not-just-a-legacy-problem" FAQ
Message-Id: <6fog6e$cs@newsops.execpc.com>
yoboseyo (yoboseyo42@hotmail.com) wrote:
: I hate reading or viewing news reports about the 'YEAR 2000 BUG"
You don't explain why very well.
: argh
: run and scream effects excluded here. One lengthy document wrote of
: hospital machines which would not work after the year 2000. Hmm, I
: thought, I have a friend who likes to mess about with basic. Maybe I
: will write him a basic prog based on this and see if he can make a
: fix.
Why? Another academic exercise in futility? Why not fix these
hospital systems yourself?
: I wanted to include the article with the routine but I could not write
: a 2000 bug into this simple maintenance checking routine as described.
: The machine would never "stop working suddenly and kill someone",
: rather it would have to wait more than a century before it stopped and
: requested maintenance checking!
You seem so sure, you must have programmed these systems.
: Point being, sensationalism! This guy knew nuts about what he wrote.
You point out one thing and run with it. Until we can all see
some code here that would/wouldnot fail, this is all opinion from both
sides. I have seen with my own eyes systems that will fail, although not
as glamorous as embedded controllers buried in the ocean floor or
satellites systems.
: The problem is there, but misunderstood! Journalists should write news
: while programmers should make use of all that storage space and ram so
: that the journalist can keep reporting the news.
Journalists write "news" based on percieved problems with society
and infrastructure. The billions of 2000 bugs definately fall into
infrastructure problems. They may not be doing a good job at explaining
it, but they are doing their job of raising awareness.
Or should awareness of the problem be hushed and put under the
rug?
: By the way, nicely researched letter you created. Also, I NEVER wrote
: a program which contained the "milenium bug" ( which is so stupid!!!!
: its a bloody century bug!!! argh!!!). I wrote all programs on an amiga
: which uses seconds since their 'incept date' 1st Jan 1979. (yes,
: that's a fact jack!) So, how many years in 28 bits worth of seconds?
: (4 bits for 16ths of a second...)
This is interesting. 28 bits of second resolution gives you 8.5
years from Jan 1st, 1979. Here, do the math:
2^28: 268,435,456 seconds
div 60 4,473,924 minutes
div 60 74,565 hours
div 24 3,107 days (rounded)
div 365.25 8.5062 years
Meaning your code, if critical, would be part of the problem, and
should have rolled over the first time as of, oh, say June 1987...The next
rollover occurred Jan 1995, and the next one should occur June 2002.
This y2k stuff bored me too until about 3 months ago - my
awareness of the issue is rising.
...Rodney
(I trimmed comp perl,javascript and object from followups)
: Zooko Journeyman <zooko@xs4all.nl> wrote:
------------------------------
Date: Mon, 30 Mar 1998 11:23:13 -0500
From: Theran Cochran <theranc@geocities.com>
Subject: Re: The "Y2k-bugs-are-not-just-a-legacy-problem" FAQ
Message-Id: <351FC6F1.F91DCD@geocities.com>
yoboseyo wrote:
> that's a fact jack!) So, how many years in 28 bits worth of seconds?
> (4 bits for 16ths of a second...)
Lets see
60 seconds in a minute
60 minutes in an hour
24 hours in a day
* 365 days in a year
--------
31536000 seconds in a year (well, approximately.
Didn't account for leap years, leap seconds, or
relativistic distortion)
2^28 = 268435456 different possible values in a 28 bit field
268435456
--------- = 8.512 years in 28 bits worth of seconds
3513600
So the answer to
your question is: Not many.
There are 136.192 years in a 32 bit field though (hence the year 2036
bug in most Unix programs, or is that year 2106? I can't remember), and
584,942,417,355.1 years in a 64 bit field. Or about 100,000 times as
long as multicellular life has existed on earth, plus a month to
recompile all your programs to 128 bit date fields.
---
Theran Cochran - theranc@geocities.com
http://www.geocities.com/SiliconValley/Way/8201
------------------------------
Date: 30 Mar 1998 16:59:50 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: The "Y2k-bugs-are-not-just-a-legacy-problem" FAQ
Message-Id: <6foj26$b7p$1@marina.cinenet.net>
Theran Cochran (theranc@geocities.com) wrote:
: Lets see
:
: 60 seconds in a minute
: 60 minutes in an hour
: 24 hours in a day
: * 365 days in a year
: --------
: 31536000 seconds in a year (well, approximately.
One of the more useful factoids I've encountered is "pi seconds is a
nanocentury." It's easy to remember, accurate to well within 1%, and
makes long-interval time calculations in seconds easier to do in your
head.
: Didn't account for leap years, leap seconds, or
: relativistic distortion
For shame! Some of us out here are running webservers travelling at high
fractions of c!
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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 V8 Issue 2209
**************************************