[15580] in Perl-Users-Digest
Perl-Users Digest, Issue: 2993 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 9 18:06:11 2000
Date: Tue, 9 May 2000 15:05:33 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <957909932-v9-i2993@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 9 May 2000 Volume: 9 Number: 2993
Today's topics:
Re: 1xPERL PROGRMMER NEEDED... <pagesusa@hotmail.com>
Re: 1xPERL PROGRMMER NEEDED... (Andreas Ringstad)
Re: 1xPERL PROGRMMER NEEDED... (David H. Adler)
Accessing Perl code parser (Rodney Broom)
Re: Accessing Perl code parser <rootbeer@redcat.com>
Re: Accidental Creation of Static Variable (Abigail)
Re: Accidental Creation of Static Variable <sariq@texas.net>
Re: after the whatever.cgi? question? <lr@hpl.hp.com>
Re: after the whatever.cgi? question? <lr@hpl.hp.com>
Re: after the whatever.cgi? question? <tony_curtis32@yahoo.com>
Re: after the whatever.cgi? question? <jeff@vpservices.com>
Re: after the whatever.cgi? question? (Jerome O'Neil)
Re: after the whatever.cgi? question? <nospam@devnull.com>
Re: after the whatever.cgi? question? <nospam@devnull.com>
Re: after the whatever.cgi? question? <lr@hpl.hp.com>
Re: after the whatever.cgi? question? (Jerome O'Neil)
Re: AIX perl 5.6 compile garrem@my-deja.com
Array of Structs. nfin8axs@hotmail.com
Re: Array of Structs. <tina@streetmail.com>
Re: Array of Structs. <lr@hpl.hp.com>
Re: Array of Structs. <andrew.mcguire@walgreens.com>
Re: Array of Structs. <mjcarman@home.com>
Re: Array of Structs. <sariq@texas.net>
Re: BEGIN and use <andrew.mcguire@walgreens.com>
Re: BEGIN and use <iltzu@sci.invalid>
Re: BEGIN and use <lr@hpl.hp.com>
Re: BEGIN and use <bmb@ginger.libs.uga.edu>
Re: BEGIN and use <andrew.mcguire@walgreens.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 09 May 2000 19:33:52 GMT
From: "AztecOne / Chris" <pagesusa@hotmail.com>
Subject: Re: 1xPERL PROGRMMER NEEDED...
Message-Id: <AKZR4.5117$P55.18553@typhoon.tampabay.rr.com>
>I can't afford to pay anyone the usual fees, so I need someone who'll
>help me out with this for a very reasonable price. But I also don't
>want or expect anyone to work for free
<Snip>
if I can get this project off the ground,
>which I fully expect to, I'll be asking you to set up a couple more
>sites in the very near future (if you're interested).
>
>If anyone can help, please email, and thanks.
>
When you ask on group, you should not expect personal email back.
You seem to assume our prices are unreasonable. Our prices are not
unreasonable.
All the information you need is available on-line and in books. That is how
we all learned. Search the web, and find tutorials.
The possibility of getting paid for some future site you may do will not
interest anyone that knows anything. You will find that you either need to
learn it, or need to pay for it.
Generally, you can find someone to install a program for a very reasonable
price. Our hosting company does it for our customers all the time. It is
that part about sitting around explaining to you what you need to learn for
yourself that will cost you.
Start with HTML. Take the HTML tutorial at www.webmonkey.com. Since you
consider yourself a quick study, this should only take a day or so. :)
Good Luck
Chris
www.pagesusa.com
------------------------------
Date: 9 May 2000 17:20:39 -0400
From: aringsta@panix.com (Andreas Ringstad)
Subject: Re: 1xPERL PROGRMMER NEEDED...
Message-Id: <8f9vf7$a94$1@panix.com>
In article <AKZR4.5117$P55.18553@typhoon.tampabay.rr.com>,
AztecOne / Chris <pagesusa@hotmail.com> wrote:
>
> [snip gratuitous response to a job posting ... sort of]
don't encourage that semi-capitalist anthropoid to post jobs
here.
wth is dha?
d
--
_______________________________________________________________________
"KAUFMAN THREATENS TO BUY NBC" aringsta@panix.com
-- LA TIMES drophead www.panix.com/~aringsta
------------------------------
Date: 9 May 2000 22:04:21 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: 1xPERL PROGRMMER NEEDED...
Message-Id: <slrn8hh2r5.aeg.dha@panix2.panix.com>
On 9 May 2000 17:20:39 -0400, Andreas Ringstad <aringsta@panix.com>
wrote:
>In article <AKZR4.5117$P55.18553@typhoon.tampabay.rr.com>,
>AztecOne / Chris <pagesusa@hotmail.com> wrote:
>>
>> [snip gratuitous response to a job posting ... sort of]
>
>don't encourage that semi-capitalist anthropoid to post jobs
>here.
>
>wth is dha?
I was out of town and then jet lagged. Jeez, can't I go away for a
bit? :-/
Besides, it's about time some of the rest of you started picking up
the slack... :-)
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Perl can certainly be used as a first computer language, but it was
really designed to be a *last* computer language. - Larry Wall
------------------------------
Date: Tue, 09 May 2000 19:31:10 GMT
From: news_rodney@ugive.com (Rodney Broom)
Subject: Accessing Perl code parser
Message-Id: <8f9o16$lk2$1@nnrp02.primenet.com>
Hey all,
I'm looking for a way to parse Perl code and glean out all of the variable
names and their respecive scope. I'm guessing that the fastest way to get this
done is to just rip the parser out of Perl and recompile it for myself, but
I'm not married to that method. Any thoughts, ideas, comments?
Rodney
------------------------------
Date: Tue, 9 May 2000 12:42:56 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Accessing Perl code parser
Message-Id: <Pine.GSO.4.10.10005091239200.3921-100000@user2.teleport.com>
On Tue, 9 May 2000, Rodney Broom wrote:
> I'm looking for a way to parse Perl code and glean out all of the
> variable names and their respecive scope. I'm guessing that the
> fastest way to get this done is to just rip the parser out of Perl and
> recompile it for myself, but
You could use a compiler backend. If there's not one that does what you
want, you get to write it yourself! :-)
See the docs for the O module, and the modules B::Deparse and B::Bytecode.
Have fun with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 9 May 2000 18:19:05 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Accidental Creation of Static Variable
Message-Id: <slrn8hglkp.tin.abigail@ucan.foad.org>
On Tue, 09 May 2000 10:15:40 -0500, Tom Briles <sariq@texas.net> wrote:
++
++ Thanks for the info.
++
++ I looked through the archives and found a couple of threads in 09/1998
++ and 10/1998, but no proposed patch passed muster.
++
++ And as Abigail indirectly pointed out, it may be too late now. It could
++ wreak havoc on existing code.
++
++ Still, it could draw a warning, or be documented in perltrap.
It should only be a warning or mentioned in perltrap if it does something
else than you possibly expect. But I don't think that is the case here.
If you use 'my $foo = 3 if $bar == 16' what *do* you expect to happen
that isn't happening now?
Certainly, 'my $foo = 3 if $bar == 16' will be obscure to some
people. But that should never, ever be an excuse for a warning.
Warnings should be there to help people prevent making mistakes -
not to annoy them because they use constructs some people can't
understand.
Abigail
------------------------------
Date: Tue, 09 May 2000 13:52:06 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Accidental Creation of Static Variable
Message-Id: <39185E56.5FA17897@texas.net>
Abigail wrote:
>
> On Tue, 09 May 2000 10:15:40 -0500, Tom Briles <sariq@texas.net> wrote:
> ++
> ++ Thanks for the info.
> ++
> ++ I looked through the archives and found a couple of threads in 09/1998
> ++ and 10/1998, but no proposed patch passed muster.
> ++
> ++ And as Abigail indirectly pointed out, it may be too late now. It could
> ++ wreak havoc on existing code.
> ++
> ++ Still, it could draw a warning, or be documented in perltrap.
>
> It should only be a warning or mentioned in perltrap if it does something
> else than you possibly expect. But I don't think that is the case here.
>
> If you use 'my $foo = 3 if $bar == 16' what *do* you expect to happen
> that isn't happening now?
I expect the garbage collector to unlink $foo when it goes out of scope
(other than for the *currently* documented exceptions).
I have no problem with the 'my VAR = EXPR if COND' construct, nor with
its current behavior; however, IMHO, the particular behavior I
demonstrated in my original post should be documented (in the Persistent
Private Variables section of perlsub, not in perltrap as I recommended
earlier).
- Tom
------------------------------
Date: Tue, 9 May 2000 11:15:55 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: after the whatever.cgi? question?
Message-Id: <MPG.1381f5b85043ffe398aa2e@nntp.hpl.hp.com>
In article <87aehzrfok.fsf@shleppie.uh.edu> on 09 May 2000 08:55:39 -
0500, Tony Curtis <tony_curtis32@yahoo.com> says...
> >> On Tue, 9 May 2000 14:51:16 +0100,
> >> "Jeff Winner" <no@spaming-or-else-ill-lame-you.com> said:
>
> > say if i had whatever.cgi?chacha=lalala how do i get the
> > value of the think after the question mark (chacha) and
> > after the equals (lalala)
>
> $ perldoc CGI
>
> use CGI;
> my $val = param('chacha');
I got caught on this carelessness a couple of weeks ago.
use CGI ':standard';
...
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 9 May 2000 11:20:35 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: after the whatever.cgi? question?
Message-Id: <MPG.1381f6d23f1f5f3998aa2f@nntp.hpl.hp.com>
In article <391821DE.60A7CD4B@vpservices.com> on Tue, 09 May 2000
07:34:06 -0700, Jeff Zucker <jeff@vpservices.com> says...
...
> # check to see if there is a lalala= in the query string
> if( param('lalala') ) { ... }
Unless, of course, the value of param('lalala') is '0'.
There are other ambiguities. If the form submitted contains no field
'lalala', then the value is undefined; it it contains such a field but
no value has been assigned, then the value is "". Each of these is
FALSE, but so is '0', as I said.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 09 May 2000 13:39:34 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: after the whatever.cgi? question?
Message-Id: <87r9bb7el5.fsf@shleppie.uh.edu>
>> On Tue, 9 May 2000 11:15:55 -0700,
>> Larry Rosler <lr@hpl.hp.com> said:
> In article <87aehzrfok.fsf@shleppie.uh.edu> on 09 May
> 2000 08:55:39 - 0500, Tony Curtis
> <tony_curtis32@yahoo.com> says...
>> >> On Tue, 9 May 2000 14:51:16 +0100, >> "Jeff Winner"
>> <no@spaming-or-else-ill-lame-you.com> said:
>>
>> > say if i had whatever.cgi?chacha=lalala how do i get
>> the > value of the think after the question mark
>> (chacha) and > after the equals (lalala)
>>
>> $ perldoc CGI
>>
>> use CGI; my $val = param('chacha');
> I got caught on this carelessness a couple of weeks ago.
> use CGI ':standard'; ...
I debated putting :standard or :all or something as I was
writing it, but I didn't, in order to remove extraneous
stuff from the context. Should we all "standard"ise
(ahem) on
use CGI qw/:standard/;
in all examples if there's no other context (e.g. wanting
HTML shortcuts)?
tony
------------------------------
Date: Tue, 09 May 2000 11:39:26 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: after the whatever.cgi? question?
Message-Id: <39185B5E.CC8B1EFA@vpservices.com>
Larry Rosler wrote:
>
> In article <391821DE.60A7CD4B@vpservices.com> on Tue, 09 May 2000
> 07:34:06 -0700, Jeff Zucker <jeff@vpservices.com> says...
>
> ...
>
> > # check to see if there is a lalala= in the query string
> > if( param('lalala') ) { ... }
>
> Unless, of course, the value of param('lalala') is '0'.
>
> There are other ambiguities. If the form submitted contains no field
> 'lalala', then the value is undefined; it it contains such a field but
> no value has been assigned, then the value is "". Each of these is
> FALSE, but so is '0', as I said.
Yep, it was entirely careless of me to write it that way. I just
corrected PG on this very point last week, so it's one I (or at least my
brain, if not my fingers) is well aware of.
For those playing at home, I should have written:
if( defined param('lalala') ) { ... } And, depending on whether I
wanted to accept "" or 0 as valid values, possibly done other tests as
well.
--
Jeff
------------------------------
Date: Tue, 09 May 2000 18:49:12 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: after the whatever.cgi? question?
Message-Id: <I4ZR4.342$94.18641@news.uswest.net>
In article <87r9bb7el5.fsf@shleppie.uh.edu>,
Tony Curtis <tony_curtis32@yahoo.com> writes:
>>> On Tue, 9 May 2000 11:15:55 -0700,
>>> Larry Rosler <lr@hpl.hp.com> said:
>> I got caught on this carelessness a couple of weeks ago.
>> use CGI ':standard'; ...
>
> I debated putting :standard or :all or something as I was
> writing it, but I didn't, in order to remove extraneous
> stuff from the context. Should we all "standard"ise
> (ahem) on
>
> use CGI qw/:standard/;
>
> in all examples if there's no other context (e.g. wanting
> HTML shortcuts)?
No. I like the object oriented interfaces, and rarely import into
the main namespace.
------------------------------
Date: 9 May 2000 19:06:38 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: after the whatever.cgi? question?
Message-Id: <8f9nju$4a4$4@216.155.32.13>
In article <8f97s6$j9t$1@mail.pl.unisys.com>, "Erick Jensen"
<erick.jensen@unisys.com> wrote:
| "Jeff Winner" <no@spaming-or-else-ill-lame-you.com> wrote in message
| news:8f96du$als$1@supernews.com...
| > ## Parse the query string
| > $lsQueryString = $ENV{'QUERY_STRING'};
| > @loFields = split(/&/,$lsQueryString);
| > foreach $lsField(@loFields) {
| > ($lsFieldName,$lsFieldValue) = split(/=/,$lsField);
| > $sQuery{$lsFieldName} = $lsFieldValue;
| > }
| >
| >
| > so is $lsFieldValue = "lalala"
| > & $lsFieldName="chacha"
|
| Yes, but use the associative array $sQuery. For example:
|
| $sQuery{'chacha'} will equal "lalala"
|
| It may be easier to use the CGI module as the others have noted, but I've
| never used it.
Good lord, man, you DO NOT know what you've been missing!
I discovered CGI.pm by *accident* -- as when I first started playing
with perl a week ago, I added the comp.lag.perl.* hierarchy to my newsrc
.. and noticed the ANNOUNCE in *.modules that there was a new CGI.pm,
along with some info.. so I checked it out..
this IMMEDIATELY gave me some wonderful ideas and I was able to put
together a script in <1week (knowing nothing of perl when I started)
that :
generates an html form on the fly,
shows the results on the same page, doing calculations on some, and
error checking (and displaying errors in colored text to make them stand
out),
allows the user to resubmit error corrections,
once they have entered the 'preview mode', a "generate HTML" button is
now shown (formerly hidden) which takes the input parameters, and packs
them into a an html-formatted file,
saves the file locally
THEN displays a "link" the user can click to preview the file.
when I'm done with it, it will also
allow the user to upload a screenshot.jpg file to be attached to the
generated HTML
and FTP both to a particular location, so that the webmaster can grab
and post them to the main website.
<grin>
and .. I'm doing all this on a Macintosh. <bigger grin> all the
prototyping, and testing were done using the WebSharing control panel,
and then final segments of testing were uploaded to my ISP's personal
space to make sure of cross-platform compatibility.
works great :D *buffing nails*
GET CGI.pm, and USE it... you'll love it. there's NO way I would have
been able to get as far, this fast, without it. (nor without the kind
help of clpm denizens =;)
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: 9 May 2000 19:11:12 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: after the whatever.cgi? question?
Message-Id: <8f9nsg$4a4$5@216.155.32.13>
In article <8f98rc$k7g$1@mail.pl.unisys.com>, "Erick Jensen"
<erick.jensen@unisys.com> wrote:
| "Jeff Zucker" <jeff@vpservices.com> wrote in message
| news:3918243D.99821873@vpservices.com...
| > Erick Jensen wrote:
| > >
| > > The part after the ? is called the query string.
| >
| > That's true.
| >
| > > The following code should work:
| > >
| > > ## Parse the query string
| > > $lsQueryString = $ENV{'QUERY_STRING'};
| >
| > Change "should work" to "may work under limited circumstances and is
| > bound to fail in other circumstances and to present security risks in
| > other circumstances". This do-it-yourself approach to parsing query
| > strings has been discussed on this newsgroup hundreds of times. Unless
| > you know what you are doing (which from this code it is evident you do
| > not), you should use CGI.pm.
Erick, your effrontery is only exceeded by your behindery. =:P
REPLIES GO AT THE BOTTOM.
PEOPLE DO NOT READ BOTTOM TO TOP.
Proper usenet Nettiquette.
| Sorry Mr. Perl Guru. I've used that bit of code for over 3 years now and
| have never had a problem. Maybe you should post your replies to
| alt.unwanted.commentary.
|
| -Erick Jensen
and anyway...
*plonk* take your abusiveness and talk to my killfile.
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Tue, 9 May 2000 12:41:02 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: after the whatever.cgi? question?
Message-Id: <MPG.138209abd12e71d98aa36@nntp.hpl.hp.com>
In article <87r9bb7el5.fsf@shleppie.uh.edu> on 09 May 2000 13:39:34 -
0500, Tony Curtis <tony_curtis32@yahoo.com> says...
> >> On Tue, 9 May 2000 11:15:55 -0700,
> >> Larry Rosler <lr@hpl.hp.com> said:
...
> > use CGI ':standard'; ...
>
> I debated putting :standard or :all or something as I was
> writing it, but I didn't, in order to remove extraneous
> stuff from the context. Should we all "standard"ise
> (ahem) on
>
> use CGI qw/:standard/;
>
> in all examples if there's no other context (e.g. wanting
> HTML shortcuts)?
I hope you weren't quibbling about my choice of quote delimiters (two-
stroke penalty to yours :-).
About six months ago, I was experimenting with FastCGI and PerlEx to
speed up CGI programs with DBI interfaces, and came across a
recommendation to use the OO style rather than direct function calls,
because of issues relating to unwanted data persistence from one
invocation to the next.
I can't locate the documentation at the moment, but I think the issue
should be considered.
There are other issues with the function-call style, such as the
pollution of the namespace that leads to conflicts between the CGI tr()
function and the Perl tr() builtin, for example.
If anything, I have found that $Q->foo() makes the CGI calls easier to
spot, despite the four-stroke handicap on each. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 09 May 2000 20:04:28 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: after the whatever.cgi? question?
Message-Id: <gb_R4.431$94.21316@news.uswest.net>
In article <8f9nsg$4a4$5@216.155.32.13>,
The WebDragon <nospam@devnull.com> writes:
> Erick, your effrontery is only exceeded by your behindery. =:P
You owe me a new keyboard, and I have to go fill my coffee cup, and
change my shirt.
Stop that!
------------------------------
Date: Tue, 09 May 2000 20:12:45 GMT
From: garrem@my-deja.com
Subject: Re: AIX perl 5.6 compile
Message-Id: <8f9rfd$tof$1@nnrp1.deja.com>
In article <8f95fm$3hc$1@nnrp1.deja.com>,
garrem@my-deja.com wrote:
> OTOH, I'm having some trouble with the AIX compiler (AIX 4.3.3 and
> C for AIX 4.4.0.2). Configure -de runs fine, with all defaults taken.
> [...]
To followup my own post, i solved the initial compile problems by
editing config.sh and removing all references to local include/lib
paths that Configure had decided to use all on its own. Now, the build
goes fine until i get what seems to be a Perl error while making the
Dynaloader:
Making DynaLoader (static)
"File::Basename" is not exported by the Cwd module
at ../../lib/ExtUtils/MM_Unix.pm line 5
"basename" is not exported by the Cwd module
at ../../lib/ExtUtils/MM_Unix.pm line 5
"dirname" is not exported by the Cwd module
at ../../lib/ExtUtils/MM_Unix.pm line 5
Can't continue after import errors at ../../lib/ExtUtils/MM_Unix.pm
line 5
BEGIN failed--compilation aborted at ../../lib/ExtUtils/MM_Unix.pm line
5.
Compilation failed in require at ../../lib/ExtUtils/MakeMaker.pm line
75.
Compilation failed in require at Makefile.PL line 1.
BEGIN failed--compilation aborted at Makefile.PL line 1.
Warning: No Makefile!
make[1]: Entering directory `/usr/local/packages/perl-
5.6.0/ext/DynaLoader'
make[1]: *** No rule to make target `config'. Stop.
make[1]: Leaving directory `/usr/local/packages/perl-
5.6.0/ext/DynaLoader'
make config failed, continuing anyway...
make[1]: Entering directory `/usr/local/packages/perl-
5.6.0/ext/DynaLoader'
make[1]: *** No rule to make target `all'. Stop.
make[1]: Leaving directory `/usr/local/packages/perl-
5.6.0/ext/DynaLoader'
make: *** [lib/auto/DynaLoader/DynaLoader.a] Error 2
Any ideas?
Thanks,
-Matt
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 09 May 2000 18:42:34 GMT
From: nfin8axs@hotmail.com
Subject: Array of Structs.
Message-Id: <8f9m6m$nc6$1@nnrp1.deja.com>
I am fairly new to perl, and am having one primary difficulty:
I have so far been unsuccessful with crating an array of structs.
eg I want an array with 50,000 slots, but I want each slot to contain a
record with three slots (something like : array[30].A = 'something' the
a field of the 30th box in the array contains the string "something") .
What is the syntax for declaring such a data type can someone provide an
example of how do do such a thing without having to use a hash table?
Thank You.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 09 May 2000 16:12:38 -0400
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Array of Structs.
Message-Id: <8f9rff$a5ejb$1@fu-berlin.de>
hi,
nfin8axs@hotmail.com wrote:
> I am fairly new to perl, and am having one primary difficulty:
> I have so far been unsuccessful with crating an array of structs.
yeah, because AFAIK there are no structs in perl,
> eg I want an array with 50,000 slots, but I want each slot to contain a
> record with three slots (something like : array[30].A = 'something' the
> a field of the 30th box in the array contains the string "something") .
> What is the syntax for declaring such a data type can someone provide an
> example of how do do such a thing without having to use a hash table?
why don't you want a hash?
so you could write:
${$array[30] }->{"A"} = "something";
${$array[30] }->{"B"} = "something else";
that's the same as a struct, I would say, or it has
got the same functionality.
just the syntax is different...
tina
--
--- ICQ #73179850 --- | _ enter the
http://user.berlin.de/~tina.mueller | __| |___ ___ _ _ ___
---- tina's moviedatabase ----| / _` / _ \/ _ \ '_(_-< of
--search & add comments or reviews--| \__,_\___/\___/_| /__/ perception
------------------------------
Date: Tue, 9 May 2000 13:16:53 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Array of Structs.
Message-Id: <MPG.1382121412a2580998aa37@nntp.hpl.hp.com>
In article <8f9m6m$nc6$1@nnrp1.deja.com> on Tue, 09 May 2000 18:42:34
GMT, nfin8axs@hotmail.com <nfin8axs@hotmail.com> says...
> I am fairly new to perl, and am having one primary difficulty:
> I have so far been unsuccessful with crating an array of structs.
> eg I want an array with 50,000 slots, but I want each slot to contain a
> record with three slots (something like : array[30].A = 'something' the
> a field of the 30th box in the array contains the string "something") .
> What is the syntax for declaring such a data type can someone provide an
> example of how do do such a thing without having to use a hash table?
perldoc perldsc
perldoc perllol
From your problem description, if the data aren't sparse, an array of
array(reference)s will probably suit your needs. But be prepared to use
lots of memory, because of structure overhead.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 09 May 2000 15:21:10 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: Array of Structs.
Message-Id: <39187336.C156BB3@walgreens.com>
nfin8axs@hotmail.com wrote:
>
> I am fairly new to perl, and am having one primary difficulty:
> I have so far been unsuccessful with crating an array of structs.
> eg I want an array with 50,000 slots, but I want each slot to contain a
> record with three slots (something like : array[30].A = 'something' the
> a field of the 30th box in the array contains the string "something") .
> What is the syntax for declaring such a data type can someone provide an
> example of how do do such a thing without having to use a hash table?
#!/usr/bin/perl -w
use strict;
# A list of lists.
my @LoL = ( [ 0, 1, 2 ],
[ 3, 4, 5 ],
[ 6, 7, 8 ] );
# Print all elements in matrix.
print @{$_} for @LoL;
You may also want to look at:
perldoc perldsc
perldoc perllol
Cheers,
anm
--
Andrew N. McGuire
andrew.mcguire@walgreens.com
------------------------------
Date: Tue, 09 May 2000 15:29:55 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Array of Structs.
Message-Id: <39187543.E3F1F37B@home.com>
nfin8axs@hotmail.com wrote:
>
> I am fairly new to perl, and am having one primary difficulty:
> I have so far been unsuccessful with crating an array of structs.
Unlike many (most) other languages, Perl doesn't create arrays "of"
anything. You just create an array and can put any scalar value into
each element.
> [...] each slot to contain a record with three slots (something
> like : array[30].A = 'something'
This isn't how OO Perl looks, but I know what you're after...
> What is the syntax for declaring such a data type
Fundamentally, what you need to do is create an array of hashrefs. There
are a number of ways to do it, depending on just what you're after. The
simplest would be to just initialize it and let perl handle any
necessary autovivifications:
$array[30]{A} = 'something'
But if you want a more OO feel, including methods, look into the
Class::Struct module. Also, type 'perldoc -q struct' at your command
line for what the FAQ has to say, and look into 'perldoc perltoot'
-mjc
------------------------------
Date: Tue, 09 May 2000 15:50:33 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Array of Structs.
Message-Id: <39187A19.1F3BEF94@texas.net>
nfin8axs@hotmail.com wrote:
>
> I am fairly new to perl, and am having one primary difficulty:
> I have so far been unsuccessful with crating an array of structs.
perldoc -q struct
- Tom
------------------------------
Date: Tue, 09 May 2000 13:02:45 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: BEGIN and use
Message-Id: <391852C5.7C00E935@walgreens.com>
Larry Rosler wrote:
[ snip ]
> Whereas in C, a 'null statement' consists of a semicolon.
>
> That all makes sense, though I wonder how many Perl programmers writing
> a block like
>
> {
> STATEMENT;
> STATEMENT;
> }
>
> realize that there are *three* statements in the body of the block.
> (Operationally, it doesn't matter, of course.)
I am afraid I don't follow you here. Could you please explain
this in a little more detail?
Cheers,
anm
--
Andrew N. McGuire
andrew.mcguire@walgreens.com
------------------------------
Date: 9 May 2000 18:26:58 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: BEGIN and use
Message-Id: <957896130.1735@itz.pp.sci.fi>
In article <Pine.A41.4.10.10005091314090.8776-100000@ginger.libs.uga.edu>, Brad Baxter wrote:
>On the other hand, why wouldn't there be 7 elements in the array:
>
> @a = split //, 'abc';
Because split doesn't return the delimiters unless you ask for them,
of course.
@a = split /()/, 'abc';
You'll still get only five, though, unless you give a negative limit
as documented in "perldoc -f split". Then you'll get seven elements,
even though they might not be int the order you'd expect. But I guess
splitting null strings is going even _beyond_ splitting hairs..
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Tue, 9 May 2000 12:04:48 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: BEGIN and use
Message-Id: <MPG.1382012de057702298aa32@nntp.hpl.hp.com>
In article <391852C5.7C00E935@walgreens.com> on Tue, 09 May 2000
13:02:45 -0500, Andrew N. McGuire <andrew.mcguire@walgreens.com> says...
> Larry Rosler wrote:
...
> > That all makes sense, though I wonder how many Perl programmers writing
> > a block like
> >
> > {
> > STATEMENT;
> > STATEMENT;
> > }
> >
> > realize that there are *three* statements in the body of the block.
> > (Operationally, it doesn't matter, of course.)
>
> I am afraid I don't follow you here. Could you please explain
> this in a little more detail?
Well, as we now know, a semicolon is a statement separator, not a
statement terminator. So there is a null statement after the second
semicolon and before the closing brace.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 9 May 2000 15:29:39 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: BEGIN and use
Message-Id: <Pine.A41.4.10.10005091528510.8776-100000@ginger.libs.uga.edu>
On Tue, 9 May 2000, Larry Rosler wrote:
> In article <391852C5.7C00E935@walgreens.com> on Tue, 09 May 2000
> 13:02:45 -0500, Andrew N. McGuire <andrew.mcguire@walgreens.com> says...
> > Larry Rosler wrote:
>
> ...
>
> > > That all makes sense, though I wonder how many Perl programmers writing
> > > a block like
> > >
> > > {
> > > STATEMENT;
> > > STATEMENT;
> > > }
> > >
> > > realize that there are *three* statements in the body of the block.
> > > (Operationally, it doesn't matter, of course.)
> >
> > I am afraid I don't follow you here. Could you please explain
> > this in a little more detail?
>
> Well, as we now know, a semicolon is a statement separator, not a
> statement terminator. So there is a null statement after the second
> semicolon and before the closing brace.
... light dawns ...
--
Brad
------------------------------
Date: Tue, 09 May 2000 15:05:07 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: BEGIN and use
Message-Id: <39186F73.96D29FFA@walgreens.com>
Larry Rosler wrote:
>
> In article <391852C5.7C00E935@walgreens.com> on Tue, 09 May 2000
> 13:02:45 -0500, Andrew N. McGuire <andrew.mcguire@walgreens.com> says...
> > Larry Rosler wrote:
>
> ...
>
> > > That all makes sense, though I wonder how many Perl programmers writing
> > > a block like
> > >
> > > {
> > > STATEMENT;
> > > STATEMENT;
> > > }
> > >
> > > realize that there are *three* statements in the body of the block.
> > > (Operationally, it doesn't matter, of course.)
> >
> > I am afraid I don't follow you here. Could you please explain
> > this in a little more detail?
>
> Well, as we now know, a semicolon is a statement separator, not a
> statement terminator. So there is a null statement after the second
> semicolon and before the closing brace.
Ah, I see (I think), and if you had said:
{
STATEMENT;
STATEMENT
}
it would only be two statements, interesting. Thank you.
Cheers,
anm
--
Andrew N. McGuire
andrew.mcguire@walgreens.com
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 2993
**************************************