[12682] in Perl-Users-Digest
Perl-Users Digest, Issue: 91 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 9 13:07:16 1999
Date: Fri, 9 Jul 1999 10:05:11 -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 Fri, 9 Jul 1999 Volume: 9 Number: 91
Today's topics:
Re: 'making' perl <elaine@chaos.wustl.edu>
Re: 3 virtues of a Programmer <elaine@chaos.wustl.edu>
Re: 3 virtues of a Programmer <elaine@chaos.wustl.edu>
Re: array stuff.. (Larry Rosler)
Re: array stuff.. <mdz4c@node12.unix.Virginia.EDU>
Re: array stuff.. (Larry Rosler)
Re: Assocative Arrays (Greg Bacon)
Re: Carriage returns <dsparling@my-deja.com>
Could anybody help me with this?? <newsgrouppost@smartmedia.nl>
DNS question then sorting by values (Kevin Johnson)
getpwent will not share array data outside while. <john@hendigital.com.au>
Re: Help with .pl script execution problem (Mike Bristow)
installation on unixware4.2 problems <paul.glidden@unisys.com>
Re: Pattern match counting (Greg Bacon)
Re: please help regex! (John Borwick)
Q:a simple update to index <m-andric@students.uiuc.edu>
Re: regex to eat all html tags (or check your faqs, Jac <emschwar@rmi.net>
saving process output to a log file using Win32::Proces amidalla@my-deja.com
Re: Self-referencing hash? Ick? <uri@sysarch.com>
Re: Strangeness re $#{$test{'foo'}{'bar'}} (John Borwick)
Re: Strangeness re $#{$test{'foo'}{'bar'}} <stampes@xilinx.com>
Re: Too late for "-T" option at init.cgi line 1. (Greg Bacon)
Re: Too late for "-T" option at init.cgi line 1. (John Borwick)
unpack problems sds@goems.com
Re: unpack problems (Greg Bacon)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 9 Jul 1999 11:44:19 -0500
From: elaine ashton <elaine@chaos.wustl.edu>
To: henning hummert <hummerth@egr.msu.edu>
Subject: Re: 'making' perl
Message-Id: <Pine.GSO.4.05.9907091141130.21584-100000@chaos.wustl.edu>
[courtesy copy mailed to original author]
> i am trying to install a new version of perl on a linux box. problem is:
> i can run the Configure script without any trouble, make dep is running
> well too, but when i try to run make i get an error saying : error in
> makefile pointing to the last line of it.
Impossible to say for certain without a copy of the error. However, you
might look at the makefile to see what it is griping about. You might also
run 'sh Configure -des' and see if that fixes it. Read the INSTALL
document in the source as well.
Also, check your shell env and, if this is redhat, check the growing
errata page for things such as 'make is hosed' or something.
enjoy.
e.
--
-=]) elaine ashton // elaine@chaos.wustl.edu // HFB ([=-
-=]) A dismal wasteland of banality, cliche' and casual obscenity ([=-
------------------------------
Date: Fri, 9 Jul 1999 11:35:24 -0500
From: elaine ashton <elaine@chaos.wustl.edu>
To: Simon Twigger <simont@mcw.edu>
Subject: Re: 3 virtues of a Programmer
Message-Id: <Pine.GSO.4.05.9907091120190.21584-100000@chaos.wustl.edu>
[courtesy copy mailed to original author]
> a more complete explanation for the 3 virtues of programmers as
> defined by Larry Wall a while back:
You might have a look at http://history.perl.org/ There is a section of
links to Larry's speeches and articles down at the bottom of the timeline.
In particular, you will want to read the 1st(0th?) State of the Onion.
> 3. Hubris.
>
> 1 & 2 I can figure out but #3 is proving more of a problem. I seem to
> remember he covered this in more detail in the books but someone
> borrowed my Programming Perl vol.1 and I cant seem to find too much in
> Vol.2
Pride or arrogance. Geek with an attitude.
It is not mentioned in the Camel, the Llama or the Nutshell as far as I
recall.
e.
-=]) elaine ashton // elaine@chaos.wustl.edu // HFB ([=-
-=]) A dismal wasteland of banality, cliche' and casual obscenity ([=-
------------------------------
Date: Fri, 9 Jul 1999 11:38:54 -0500
From: elaine ashton <elaine@chaos.wustl.edu>
Subject: Re: 3 virtues of a Programmer
Message-Id: <Pine.GSO.4.05.9907091136470.21584-100000@chaos.wustl.edu>
> Simon Twigger wrote:
> >
> > 3. Hubris.
>
> The pink camel, page 424:
Rats! I gave my pink camel away once while on a layover in BWI upon seeing
this geek reading a shell programming book.
Maybe I'll go search for another copy on ebay :)
e.
------------------------------
Date: Fri, 9 Jul 1999 09:24:32 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: array stuff..
Message-Id: <MPG.11efc20ab66079fe989c7e@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <378615A6.8736FB08@americasm01.nt.com> on Fri, 09 Jul 1999
10:30:46 -0500, Marshall Culpepper <marshalc@americasm01.nt.com> says...
> hey kind of an intermediate skill level on perl..
> is there any quick function to add a certain string to every element of
> an array
> i.e;
> $str="a";
> @test=('0'..'5');
> and test would return as ('a0'..'a5')? any help would be greatly
> appreciated :)
$_ = "$str$_" for @test;
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 9 Jul 1999 12:37:36 -0400
From: Matthew Zimmerman <mdz4c@node12.unix.Virginia.EDU>
Subject: Re: array stuff..
Message-Id: <Pine.A41.4.05.9907091233350.54138-100000@node12.unix.Virginia.EDU>
On Fri, 9 Jul 1999, Marshall Culpepper wrote:
> is there any quick function to add a certain string to every element of
> an array
> i.e;
> $str="a";
> @test=('0'..'5');
> and test would return as ('a0'..'a5')? any help would be greatly
> appreciated :)
The gurus can correct me, but I don't think there is an operator
that does that. You have to step through it one at a time.
use strict;
my $str = "a";
my @test = ('0'..'5');
foreach (@test) {$_ = $str . $_}
HTH Matt
--
Matthew Zimmerman http://www.people.virginia.edu/~mdz4c
Interdisciplinary Biophysics Program University of Virginia
------------------------------------------------------------------
"You got to be very careful if you don't know where you're going,
because you might not get there." -- Yogi Berra
------------------------------
Date: Fri, 9 Jul 1999 09:35:21 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: array stuff..
Message-Id: <MPG.11efc49a4428c3d4989c7f@nntp.hpl.hp.com>
In article <MPG.11efc20ab66079fe989c7e@nntp.hpl.hp.com> on Fri, 9 Jul
1999 09:24:32 -0700, Larry Rosler <lr@hpl.hp.com> says...
> In article <378615A6.8736FB08@americasm01.nt.com> on Fri, 09 Jul 1999
> 10:30:46 -0500, Marshall Culpepper <marshalc@americasm01.nt.com> says...
> > hey kind of an intermediate skill level on perl..
> > is there any quick function to add a certain string to every element of
> > an array
> > i.e;
> > $str="a";
> > @test=('0'..'5');
> > and test would return as ('a0'..'a5')? any help would be greatly
> > appreciated :)
>
> $_ = "$str$_" for @test;
I omitted one sentence in my response:
perlfaq4: "How do I process/modify each element of an array?"
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 9 Jul 1999 16:31:02 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Assocative Arrays
Message-Id: <7m5846$ark$2@info2.uah.edu>
In article <slrn7oaul1.5k.abigail@alexandra.delanet.com>,
abigail@delanet.com (Abigail) writes:
: Too bad we can't do (without the use of do{}):
:
: {local $, = "\n";
: print for (values %$_) for (values %$_) for (values %$_) for (values %hash);
: }
For that to be legal syntax, wouldn't something like
print "True!\n" if $foo if $bar if $baz if $quux;
also have to be legal?
Greg
--
Isn't it weird that we drink milk, stuff designed to nourish baby cows? How did
THAT happen? Did some cattleman once say, "Oh, man, I can't wait till them
calves are done so I can get ME a hit of that stuff."
-- Jerry Seinfeld
------------------------------
Date: Fri, 09 Jul 1999 15:57:51 GMT
From: Douglas Sparling <dsparling@my-deja.com>
Subject: Re: Carriage returns
Message-Id: <7m565q$dgu$1@nnrp1.deja.com>
I had the same exact problem.
For a scaler, try: $textarea =~ s[\012\015]/ /g.
For an array, try: @info =~ grep(s/[\012\015]/ /g,@info);
In article <37838a75.0@news.primary.net>,
"Derek L. Babcock" <derek@ranken.org> wrote:
> I have a simple flat text database for a calendar. I have an HTML
text area
> on a page that the users can submit events for the calendar. It works
fine
> except if the user hits return after each line. In the database file
the
> entry gets screwed up because the carriage returns are making an
entry that
> should be only one line several lines. How can I have perl ignore
carriage
> returns? Thanks for any help!
>
>
--
Douglas Sparling
Web Programmer
Universal New Media
http://www.uexpress.com
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Fri, 9 Jul 1999 18:34:21 +0200
From: "E.G. van Haandel" <newsgrouppost@smartmedia.nl>
Subject: Could anybody help me with this??
Message-Id: <7m588t$g33$1@enterprise.cistron.net>
Hi,
I'm using a postcard script from and I like the script very much!!! I'm
using it on the following site (Dutch):
http://www.party2000.nl/kaart/
But there is a little thing that I would like to change... The part where
the current time and date are captured, uses the time from the server. But
the server I'm using is in the US and I'm living in the Netherlands. So the
time isn't correct. Is it possible to adjust the time difference??? And also
I would like to change the names of the month to the Dutch language. I
allready edited the '@month' variable in the 'gets the current date'
section, but that didn't do the trick...
Could anybody do a little programming for me???
The complete script is on:
http://www.aestheticsurgerycenter.com/scripts/postcard/card.txt
>>>>>>>>>>>>> This section of your script did I edit <<<<<<<<<<<<<<<<<
############################################
#Gets the Current Date
############################################
($sec,$min,$hr,$day,$month,$year,$day_of_week,$day_of_year,$some) =
localtime(time);
@months =
("januari","februari","maart","april","mei","juni","juli","augustus","septem
ber","oktober","november","december");
$minute = $min + 10;
$hour = $hr + 10;
$second = $sec + 10;
$DATE = `date +"%d-%B-%Y.dat"`;
chop ($DATE);
$SHORTDATE = `date +"%d %B, %Y om %T %Z""`;
chop ($SHORTDATE);
Best regards,
Emiel van Haandel
------------------------------
Date: 9 Jul 1999 16:22:39 GMT
From: kevin@prism.ig.utexas.edu (Kevin Johnson)
Subject: DNS question then sorting by values
Message-Id: <7m57kf$en2$1@geraldo.cc.utexas.edu>
Hi.
I'm writing a log file analyser in Perl (obviously) and have
run into a couple of questions. Hopefully, they are easy :-)
First,
I downloaded the Net::DNS package and can get some basic things
to work. What I would like to do though, is search by IP address
and pick up the reverse name lookup (ip.in-addr.arpa) When I
try this, though I get
***
*** WARNING!!! The program has attempted to call the method
*** "address" for the following RR object:
***
*** xxx.xxx.xxx.xxx.in-addr.arpa. 86400 IN PTR xxx.xxx.xxx.xxx
<I've cut my IP address and replaced with x's here.>
***
*** This object doesn't have a method "address". THIS IS A BUG
*** IN THE CALLING SOFTWARE, which has incorrectly assumed that
*** the object would be of a particular type. The calling
*** software should check the type of each RR object before
*** calling any of its methods.
***
*** Net::DNS has returned undef to the caller.
***
I read this and tried screening for several different RR types. The
program would never actually find what the types specified.
Also, is this a dumb way to do this? I was planning on creating
a lookup file to speed things a bit, but it may be there is a
better way to do this?
(The motivation is to generate statistics from a web server and
print information about various domains.)
Second, I have the following bit of code to create the aforementioned
statistics:
sub addTarget {
local($target)=@_;
if (defined($target)) {
targetExists: {
foreach $name (@targetNames) {
if ($target eq $name) {
$targetSums{$target}++;
last targetExists;
}
}
$targetNames[++$#targetNames] = $target;
$targetSums{$target}=1;
}
}
}
What I want to do after this is sort by the values in %targetSums
and print the value with the corresponding key. This is opposite
of what you usually do I know. The immediate way I thought of doing
this was by copying the assoc array to another with keys and values
swapped. I did this by
while (($key,$value) = each %targetSums) {
$sumByTarget{$value}=$key;
}
foreach $key (sort keys(%sumByTarget)) {
print $key,"\t",$value,"\n";
}
Is there a better way to do what I'm trying to do?
Thanks in advance for your help.
Kevin Johnson
--
Kevin Johnson University of Texas
Systems Analyst Institute for Geophysics
------------------------------
Date: 10 Jul 1999 00:56:18 -0800
From: "John Hennessy" <john@hendigital.com.au>
Subject: getpwent will not share array data outside while.
Message-Id: <01beca2b$8b3d2fc0$f34f39cb@stingray>
I have used the following example from the Learning Perl book and printing
the values of
$login, $group, $name inside of the while is fine. If I attempt a foreach
$login (@list) outside
of the while I get an empty list. I can't find anthying to suggest that it
is private.
What am I missing ?
setpwent();
while (@list = getpwent())
{
($login,$group,$name) = @list[0,3,5];
$HoL{$group} = [ @list[0,3,5] ];
if ($group >= 500)
{
# Do stuff
}
endpwent();
Thanks
John.
------------------------------
Date: Fri, 09 Jul 1999 16:36:18 GMT
From: mike@fat.dotat.at (Mike Bristow)
Subject: Re: Help with .pl script execution problem
Message-Id: <slrn7oc989.hv7.mike@lindt.fat.dotat.at>
On Fri, 09 Jul 1999 15:33:25 GMT, fvultee@my-deja.com <fvultee@my-deja.com> wrote:
>Just click on subscribe or unsubscribe and click the button. It should
>process the request, but instead displays the text of the .pl script.
>
>Any ideas would be greatly apprecaited!
You have not correctly configured your webserver.
Try reading the docs, then try asking people who know about Sambar
Web Server.
--
Mike Bristow, Geek-At-Large. GK/RM0501
one tequila - two tequila - three tequila - FLOOR !!!
------------------------------
Date: Fri, 9 Jul 1999 11:25:18 -0500
From: "Paul Glidden" <paul.glidden@unisys.com>
Subject: installation on unixware4.2 problems
Message-Id: <7m57pj$qo6$1@bbnews1.unisys.com>
Unfortunately I need your help again on a different OS this time.
Configure was ran using -des extensions.
When trying to run the make, I received this error for various c libraries.
The make appeared to finish ok, but then when I tried to run the test, it
began trying to relink various libraries.
`sh cflags libperl.so pp_sys.o` -Kpic pp_sys.c
CCCMD =
/bin/cc -DPERL_CORE -c -I/usr/include -I/usr/ucbinclude -I/usr/local/include
-O
UX:acomp: WARNING: "pp_sys.c", line 1265: argument is incompatible with
prototype: arg #6
UX:acomp: WARNING: "pp_sys.c", line 1839: argument is incompatible with
prototype: arg #3
UX:acomp: WARNING: "pp_sys.c", line 1934: argument is incompatible with
prototype: arg #5
UX:acomp: WARNING: "pp_sys.c", line 2003: argument is incompatible with
prototype: arg #3
UX:acomp: WARNING: "pp_sys.c", line 2007: argument is incompatible with
prototype: arg #3
The following is the output from the ./myconfig script
Summary of my perl5 (5.0 patchlevel 4 subversion 1) configuration:
Platform:
osname=svr4.2mp, osvers=2.1.2, archname=i386-svr4.2mp
uname='ih19 ih19 4.2mp 2.1.2 i386 x86at '
hint=previous, useposix=true, d_sigaction=define
bincompat3=y useperlio=undef d_sfio=undef
Compiler:
cc='/bin/cc', optimize='-O', gccversion=
cppflags='-I/usr/include -I/usr/ucbinclude -I/usr/local/include'
ccflags ='-I/usr/include -I/usr/ucbinclude -I/usr/local/include'
stdchar='unsigned char', d_stdstdio=undef, usevfork=false
voidflags=15, castflags=0, d_casti32=define, d_castneg=define
intsize=4, alignbytes=4, usemymalloc=y, randbits=15
Linker and Libraries:
ld='/bin/cc', ldflags
='-L/usr/ccs/lib -L/usr/ucblib -L/usr/local/lib -L/usr/gnu/lib'
libpth=/usr/local/lib /usr/gnu/lib /shlib /lib /usr/lib /usr/ccs/lib
/usr/ucblib
libs=-lsocket -lnsl -lgdbm -ldbm -ldl -lld -lm -lc -lcrypt -lucb -lx
libc=/lib/libc.so, so=so
useshrplib=true, libperl=libperl.so
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-Kpic',
lddlflags='-G -L/usr/ccs/lib -L/usr/ucblib -L/usr/local/
lib -L/usr/gnu/lib'
Again, any help you can give me would be greatly appreciated
thanks
Paul
------------------------------
Date: 9 Jul 1999 16:28:14 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Pattern match counting
Message-Id: <7m57uu$ark$1@info2.uah.edu>
In article <MPG.11eec56e17ca4873989c77@nntp.hpl.hp.com>,
lr@hpl.hp.com (Larry Rosler) writes:
: In article <7m34v0$qna$2@info2.uah.edu> on 8 Jul 1999 21:24:48 GMT,
: Greg Bacon <gbacon@itsc.uah.edu> says...
: ...
: > $count = () = split /:/, $_, -1;
: >
: > puts the count in $count as expected.
:
: Gosh. That's *really* intuitive, isn't it?
It's not my responsibility to prove your claim.
: I know it's documented:
:
: "If LIMIT is negative, it is treated as if an arbitrarily large LIMIT
: had been specified."
You're ignoring
If LIMIT is unspecified or zero, trailing null fields are stripped
(which potential users of C<pop()> would do well to remember).
to focus in on questionable if not buggy behavior of split() to make
broad generalizations about the C<$scalar = () = ...> syntax.
Hey, Chip, make split() in scalar context return the number of fields
in Topaz. :-)
: But
:
: my $count = 1;
: ++$count while /:/g;
:
: *must* be clearer.
I fail to see how that follows logically. Prove your statement or
retract it.
: And we know it's faster.
We know it's faster for the particular dataset that you tested. Let
go of your performance anxiety.
: So why bother with '() =' at all?
Some people like it. TMTOWTDI. Get off our collective case.
Greg
--
Cartman: Moooooom! Kitty's being a dildo!
Mom: Well, I know a certain kitty-kitty who's sleeping with Mommy tonight!
------------------------------
Date: Fri, 9 Jul 1999 16:03:55 GMT
From: John.Borwick@sas.com (John Borwick)
Subject: Re: please help regex!
Message-Id: <37891bb2.99887781@newshost.unx.sas.com>
On Fri, 09 Jul 1999 09:47:56 -0500, Marshall Culpepper
<marshalc@americasm01.nt.com> wrote:
>> actually those words are farsi words in diffrent language!
>> so i want to only reverse the farsi words! not english ones!
[snip code]
>I think that should do it but i'm always wrong about these kinds of
>things....that searches for a non-alphanumeric so i hope your little farsi
>language doesn't contain /[a-z][A-Z][0-9]/ :P
>~marshall
Hey did you just insult somebody's culture? "Your little farsi
language"?
Also since you search for nonword characters in your code, you will
pick up many many other characters the original poster did not intend
to reverse. Like:
;<=>?@[\]^`{|}~
--
John Borwick
--
John Borwick
------------------------------
Date: Fri, 9 Jul 1999 11:24:25 -0500
From: milan andric <m-andric@students.uiuc.edu>
Subject: Q:a simple update to index
Message-Id: <Pine.GSO.4.10.9907091122470.17973-100000@ux12.cso.uiuc.edu>
i'm still fairly a newbie at programming and perl..
i'm writing a program that makes additions to an index page of links..
basically i want to keep the file's contents alphabetized, so i'm
using a string compare of existing lines with the new
line i'm adding to the index. my plan of attack looks something like
this (psuedocode):
$newline="<p><a href=\"\L$trunc/$csvfiles[$m].html\"><strong>$org</strong></a>";
open (INDEXIN, "<indexes/\L$trunc.html") || die ...;
open (INDEXOUT, ">indexes/new/\L$trunc.html") || die ...;
while ($_=<INDEXIN>) {
if (/<p><a href=.*><strong>.*</strong>/) { #look for the right line to take action on
$test = ($_ cmp $newline);#compare returns 1 or 0
}
if ($test=0){
print INDEXOUT $newline;
print INDEXOUT $_;
}
else {print INDEXOUT $_;}
}
i'm having some problems with the regular expression because it doesn't
seem like the best approach. do you have a better method or idea?
thanks!
-milan
------------------------------
Date: 09 Jul 1999 10:56:59 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: regex to eat all html tags (or check your faqs, Jack.)
Message-Id: <xkf4sjdg3s4.fsf@valdemar.col.hp.com>
Seth Rothberg <seth@home-industires> writes:
> I haven't quit my day job, that's for sure. But the organization of the faqs
> and other documentation is often difficult to traverse. Do you experienced
> Perl users forget this sometimes?
I know the Perl FAQ is not easy to search through (vie hypertext, anyhow;
the pods are very easy to grep), but the guy I was responding to couldn't
even *find* the FAQ on the web page, when it's sitting right there, out
in front, with a sign saying "FAQs" on it.
I figure if that's not enough of a clue, then there's just no hope.
-=Eric
------------------------------
Date: Fri, 09 Jul 1999 16:33:45 GMT
From: amidalla@my-deja.com
Subject: saving process output to a log file using Win32::Process
Message-Id: <7m5899$e6f$1@nnrp1.deja.com>
Using the following I spawn many child processes.
Win32::Process::Create($process,
"$child",
" -URTS_DEBUG=quit $cmdline",
0,
DETACHED_PROCESS,
".")
or print CHILD_LOG "\nFAIL Create failed: ", Error();
I have to be able to log the output of $child into a log file. This
doesn't work:
...
"$child",
" -URTS_DEBUG=quit $cmdline 2>> output_file.log",
0, ...
spawning with backticks or the open command easily allow me to use the
above redirection, but they don't give me the same benefits of the
$process->Kill, $process->Wait(), $process->GetExitCode() functions
that the Win32::Process module allow.
thanks for any help..
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 09 Jul 1999 12:10:45 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Self-referencing hash? Ick?
Message-Id: <x7btdlst16.fsf@home.sysarch.com>
>>>>> "BC" == Bernie Cosell <bernie@fantasyfarm.com> writes:
BC> [as for apologetic, no need for such with some of us: I'm a very
BC> old-line Lisp hacker and cross referenced lists and circular lists
BC> and other strange and anomalous structures are pretty common [and
BC> useful]. It is pretty easy to see cases where you might have hash
BC> a with refs to hash b in it, and hash b having refs back to hash a
BC> in it, and it all will work fine [but give the garbage collector
BC> an ulcer... :o)
not exactly an ulcer, more like amnesia. it just won't garbage collect a
circular structure as each element has a ref count >= 1 even when the
main code never refers to any element anymore. the rule is, if you are
smart enough to create circular structures, you are smart enough to
manually break the links before allowing perl to garbage collect
it. there is a recipe about this in the cookbook too.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Fri, 9 Jul 1999 15:54:46 GMT
From: John.Borwick@sas.com (John Borwick)
Subject: Re: Strangeness re $#{$test{'foo'}{'bar'}}
Message-Id: <378819e5.99426768@newshost.unx.sas.com>
0On Fri, 9 Jul 1999 10:36:06 +0000, Adam Trojanowski
<trojan@samurai.ruin.org> wrote:
>Was wondering if anyone else has noticed that an 'empty' array on a hash
>of hash of array shows up with a record count of -1 instead of 0. Also
>seems like even when it's not empty, the record count is off by -1.
>$y = $#{$test{'foo'}{'bar'}};
$# means "the index of the last element in the array" instead of "the
number of elements in the array." For the number of elements you
should call your array in a scalar context, like
$y = @{$test{'foo'}{'bar'}};
# or to be verbose
$y = scalar @{ $test{'foo'}{'bar'} };
--
John Borwick
--
John Borwick
------------------------------
Date: 9 Jul 1999 15:55:47 GMT
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: Strangeness re $#{$test{'foo'}{'bar'}}
Message-Id: <7m5623$1jb1@courier.xilinx.com>
Adam Trojanowski <trojan@samurai.ruin.org> wrote:
: Was wondering if anyone else has noticed that an 'empty' array on a hash
: of hash of array shows up with a record count of -1 instead of 0. Also
: seems like even when it's not empty, the record count is off by -1.
This is no different than a regular array, an array of arrays, or any
other permutation. And that's because you are misunderstanding what
the $#array_name should return. From the perlvar manpage:
<snip>
The length of an array is a scalar value. You may find the length of
array @days by evaluating $#days, as in csh. (Actually, it's not the
length of the array, it's the subscript of the last element, because
there is (ordinarily) a 0th element.) Assigning to $#days changes the
length of the array. Shortening an array by this method destroys
intervening values. Lengthening an array that was previously shortened
NO LONGER recovers the values that were in those elements. (It used to
in Perl 4, but we had to break this to make sure destructors were
called when expected.) You can also gain some miniscule measure of
efficiency by pre-extending an array that is going to get big.
(You can also extend an array by assigning to an element that is off
the end of the array.) You can truncate an array down to nothing by
assigning the null list () to it. The following are equivalent:
@whatever = ();
$#whatever = -1
</snip>
Thus an empty array (meaning one with no elements) will always return
-1.
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: 9 Jul 1999 16:44:52 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Too late for "-T" option at init.cgi line 1.
Message-Id: <7m58u4$ark$3@info2.uah.edu>
In article <7m55mk$dbh$1@nnrp1.deja.com>,
mike cardeiro <mikecard@my-deja.com> writes:
: Too late for "-T" option at init.cgi line 1.
Sounds like you used something like
% perl prog
to invoke your program. If you want to enable taint checking, you
need to let perl know as soon as possible. Do this like
% perl -T prog
or if you're fortunate enough to be using Unix
% chmod +x prog
% ./prog
: why is it too late and am i barking up the wrong tree by using taint
When taint checking is enabled, perl needs to make different assumptions
at initialization. By the time it finds the -T on your shebang line,
it realizes it has been making the wrong assumptions all along and
throws up its hands in defeat.
Taint checking isn't a magic pill, but it's certainly a great tool. I
use it when I'm handling untrusted data, so I couldn't say that you're
barking up the wrong tree. :-)
Greg
--
File names are infinite in length where infinity is set to 255 characters.
-- Peter Collinson
------------------------------
Date: Fri, 9 Jul 1999 16:22:22 GMT
From: John.Borwick@sas.com (John Borwick)
Subject: Re: Too late for "-T" option at init.cgi line 1.
Message-Id: <378b21a2.101408137@newshost.unx.sas.com>
On Fri, 09 Jul 1999 15:49:45 GMT, mike cardeiro <mikecard@my-deja.com>
wrote:
>i am making a program that will create and use data files. i am a
>little worried about users being able to rewrite these data files
>outside of the perl script and wreaking havoc on my site (if thats
>possible) so i searched low and high and someone suggested the taint
>option, but when i try to invoke it i get:
> Too late for "-T" option at init.cgi line 1.
are you maybe using a combination of perl -w and -T?
what other command line args are you giving?
--
John Borwick
------------------------------
Date: 09 Jul 1999 12:42:19 -0400
From: sds@goems.com
Subject: unpack problems
Message-Id: <wklncp93mc.fsf@goems.com>
I have a fixed width record and I thought that unpack was the right tool
for the job. I need to translate, say
"abcd125+0.12"
to ("abcd", 125, 0.12)
I tried unpack("%4A%3A%5A", "abcd125+0.12"), but it returns some
gibberish. what am I doing wrong?
Thanks.
[this is not a homework, if that matters]
--
Sam Steingold (http://www.goems.com/~sds) running RedHat6.0 GNU/Linux
Micros**t is not the answer. Micros**t is a question, and the answer is Linux,
(http://www.linux.org) the choice of the GNU (http://www.gnu.org) generation.
All generalizations are wrong. Including this.
------------------------------
Date: 9 Jul 1999 16:52:16 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: unpack problems
Message-Id: <7m59c0$ark$4@info2.uah.edu>
In article <wklncp93mc.fsf@goems.com>,
sds@goems.com writes:
: I have a fixed width record and I thought that unpack was the right tool
: for the job. I need to translate, say
: "abcd125+0.12"
: to ("abcd", 125, 0.12)
: I tried unpack("%4A%3A%5A", "abcd125+0.12"), but it returns some
: gibberish. what am I doing wrong?
% man perlfaq5
[...]
How can I manipulate fixed-record-length files?
The most efficient way is using pack() and unpack(). This
is faster than using substr() when take many, many
strings. It is slower for just a few.
Here is a sample chunk of code to break up and put back
together again some fixed-format input lines, in this case
from the output of a normal, Berkeley-style ps:
# sample input line:
# 15158 p5 T 0:00 perl /home/tchrist/scripts/now-what
$PS_T = 'A6 A4 A7 A5 A*';
open(PS, "ps|");
print scalar <PS>;
while (<PS>) {
($pid, $tt, $stat, $time, $command) = unpack($PS_T, $_);
for $var (qw!pid tt stat time command!) {
print "$var: <$$var>\n";
}
print 'line=', pack($PS_T, $pid, $tt, $stat, $time, $command),
"\n";
}
We've used $$var in a way that forbidden by use strict
'refs'. That is, we've promoted a string to a scalar
variable reference using symbolic references. This is ok
in small programs, but doesn't scale well. It also only
works on global variables, not lexicals.
Enjoy,
Greg
--
Comfort rides shotgun with the temporary.
-- Daniel Weinshenker
------------------------------
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 91
************************************