[16112] in Perl-Users-Digest
Perl-Users Digest, Issue: 3524 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 30 14:05:33 2000
Date: Fri, 30 Jun 2000 11:05:19 -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: <962388319-v9-i3524@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 30 Jun 2000 Volume: 9 Number: 3524
Today's topics:
Re: +<< operator - cant find string delimiter (Tad McClellan)
Re: 2nd level of reference <care227@attglobal.net>
[Q] Anybody socket-to-socket Perl on PC to mainframe (O <mitiste@charlie.iit.edu>
Re: a large amount of unique numbers in an efficient wa (Tad McClellan)
Apparent DB_File corruption <ke77le@my-deja.com>
Re: BIG BUG in CGI.pm on Internet Explorer !! <kperrier@blkbox.com>
Re: C prog access to dbi? <dan@tuatha.sidhe.org>
Re: Calling perl module from C <dan@tuatha.sidhe.org>
Re: Changing .htpasswd on the fly.. (Randal L. Schwartz)
Re: check for valid e-mail address (brian d foy)
Re: check for valid e-mail address <mike.solomon@eps.ltd.uk>
Re: check for valid e-mail address <bg@skypoint.com>
comparison question <jfisher@epotec.com>
Re: correct name space manchester_united@my-deja.com
Re: correct name space <jeffp@crusoe.net>
Re: DBI and interpolation <gellyfish@gellyfish.com>
Debugger Command <kupernik@bcn.net>
Re: Debugger Command <mike.solomon@eps.ltd.uk>
Re: Finding FatalsToEmail ? (Randal L. Schwartz)
formatting output of a process <jdigil1@uic.edu>
Re: Help with hashes <care227@attglobal.net>
Re: Help with hashes <cghansen@micron.com>
Re: Help with hashes (Andrew Johnson)
Re: how do i create an array of hashes? (Tad McClellan)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 30 Jun 2000 11:28:49 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: +<< operator - cant find string delimiter
Message-Id: <slrn8lpf5h.696.tadmc@magna.metronet.com>
On Fri, 30 Jun 2000 13:58:14 +0000, redtux <mike@cyborg-group.com> wrote:
> my $mail_message = <<__END_OF_MAIL__;
> To: $to From: $from Subject: $subject
>
> $body
>
> __END_OF_MAIL__
>This fails when at __END_OF_MAIL__ with debugging error of Can't find
>string terminator "__END_OF_MAIL__" anywhere before EOF
>
>Can anyone shed some light on this - is this depreciated?
All of the messages that perl might issue are documented in the
perldiag.pod standard doc.
Looking up a message there should be your first step (_not_
posting to Usenet) in debugging.
perldoc perldiag
For your message, it says:
-------------------------------
=item Can't find string terminator %s anywhere before EOF
(F) Perl strings can stretch over multiple lines. This message means that
the closing delimiter was omitted. Because bracketed quotes count nesting
levels, the following is missing its final parenthesis:
print q(The character '(' starts a side comment.);
If you're getting this error from a here-document, you may have
included unseen whitespace before or after your closing tag. A good
programmer's editor will have a way to help you find these characters.
-------------------------------
Maybe you just didn't know that the '<<' thingie is called
a "here doc"?
Because there is also:
perldoc -q "<<"
which finds:
"Why don't my <<HERE documents work?"
Either one of those would have given you the answer in seconds.
Asking on Usenet takes minutes/hours/days/forever...
Use the docs, Luke.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 30 Jun 2000 11:41:37 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: 2nd level of reference
Message-Id: <395CBFB1.A90C1697@attglobal.net>
Tad McClellan wrote:
>
>
> The program above makes the same output without the s/// !
Ugh.
------------------------------
Date: Fri, 30 Jun 2000 10:25:28 -0500
From: Stef <mitiste@charlie.iit.edu>
Subject: [Q] Anybody socket-to-socket Perl on PC to mainframe (OS/390) CICS?
Message-Id: <greplsoiahs6angb1pth6bmqcprbiem65b@4ax.com>
The title says it pretty much all: I have been asked to do
some socket-to-socket communication, with Perl on PC on one hand - to
mainframe CICS socket on the other hand. Anybody having ever dealt
with the mainframe sockets side?
TIA,
Stef
------------------------------
Date: Fri, 30 Jun 2000 11:43:36 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: a large amount of unique numbers in an efficient way?
Message-Id: <slrn8lpg18.696.tadmc@magna.metronet.com>
On Fri, 30 Jun 2000 08:39:04 GMT, Neil Kandalgaonkar <neil@brevity.org> wrote:
>In article <slrn8lofjh.mm6.bernard.el-hagin@gdndev25.lido-tech>,
>Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote:
>>On 29 Jun 2000 22:14:46 EDT, Abigail <abigail@delanet.com> wrote:
>>>Abigail
>>>--
>>>perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT
>>
>>Can someone please explain how this works?
[ snip explanation ]
>This one is a mere trifle by Abigail standards.
My favorite quote from YAPC19100 was by Abigail:
"Creating a JAPH is simple. You just need an idea, then
work out the details."
:-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 30 Jun 2000 15:19:49 GMT
From: Kostis <ke77le@my-deja.com>
Subject: Apparent DB_File corruption
Message-Id: <8jidq0$boq$1@nnrp1.deja.com>
Hi all.
I've been using the DB_File modules to achieve hash and array
persistence and they've been fantastic till now...
I have an array which is tied to a DB file through:
use DB_File;
use strict;
my @array;
my $DB_ARRAY = new DB_File::RECNOINFO;
my $dbarrayRef = tie @array, "DB_File", "DB/array.db",O_CR
EAT|O_RDWR,0666,$DB_ARRAY || "error can't tie 'array' array\n";
while (my $elem = shift @array) {
print "Just shifted $elem\n";
}
Problem is that the loop will shift through the first 40-50 elements of
the array and then:
"Segmentation fault (core dumped)"
The array had around 50000 elements the last time I looked most of
which should be no longer than 100 byte or so....
It's been working fine but for some reason it has now began to core
dump on me.
Could this crash be caused by a very large element?
How can I recover/repair the db file and get things working again?
I had a look at http://sleepycat.com/docs/utility/db_recover.html but
this seems to talk about whole database directories rather than files
generated by tied Perl structures.
Could anyone point me in the right direction?
Many Thanks,
Kostis
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 30 Jun 2000 12:19:51 -0500
From: Kent Perrier <kperrier@blkbox.com>
Subject: Re: BIG BUG in CGI.pm on Internet Explorer !!
Message-Id: <417BA9454554F635.D51501AB98E82B2C.B941BE14BC0464C6@lp.airnews.net>
That's funny, I didn't know that IE was an operating system that perl
had been ported to.
Kent
--
They were killing machines. I wanted to be them so bad.
-- Jamie Zawinski
http://www.jwz.org/gruntle/grave.html
------------------------------
Date: Fri, 30 Jun 2000 17:40:25 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: C prog access to dbi?
Message-Id: <dY475.1163$cu1.4500@news1.rdc1.ct.home.com>
cc <cpcapps@erols.com> wrote:
> We are familiar with most of the c interfaces to databases, we have written
> them for oracle, sybase, ms-sqlserver, etc. However we are looking for the
> maintainability of odbc across platforms. This system is a distributed one,
> that will need to run on all platforms, hence the interest in dbi. Can't
> the dbi modules be accessed from C, that then can be linked into Java.
> cc
if you really want to (and I think it's a bad idea--you're adding in a lot
of extra layers that could be tossed) you'll need to embed perl into your
C program and make calls into perl, whic'll then call into DBI (ultimatley
making calls into C code, and from there into the vendor's libraries).
You're probably better off either writing a portable interface layer in C
yourself or finding an ODBC doodad you can use.
Dan
------------------------------
Date: Fri, 30 Jun 2000 17:35:58 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Calling perl module from C
Message-Id: <2U475.1162$cu1.4500@news1.rdc1.ct.home.com>
sunandavenu@my-deja.com wrote:
> I would like to know if we can successfuly pass
> structures to perl from C or atleast if there is
> a way to get around this problem.
Sure. Just save off a pointer to the structure in a perl variable
somewhere (the IV slot's a popular place) and have your interface code
extract the pointer and pass it to the C library routine.
(FWIW, I saw the original posting--have you double-checked to see if the
.h files that can't be found are in either of the extra include
directories you used?)
Dan
------------------------------
Date: 30 Jun 2000 09:10:22 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Changing .htpasswd on the fly..
Message-Id: <m1r99fjgk1.fsf@halfdome.holdit.com>
>>>>> "Alan" == Alan J Flavell <flavell@mail.cern.ch> writes:
Alan> Oh dear, I'm reluctant to teach Randal to suck eggs, but he seems to
Alan> do this consistently, and in col 34 he even compounds it by coding
Alan> flock($master, 2); # LOCK_EX
Heh. I'm just trying to carry on the grand tradition started in
chat2.pl, where some included some numeric constants that I thought
were immutable, but ended up getting changed by the System V standard.
Anyway, I'll take the beating for this. My mistake.
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Fri, 30 Jun 2000 11:07:40 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: check for valid e-mail address
Message-Id: <brian-ya02408000R3006001107400001@news.panix.com>
In article <8ji440$ktg0$1@ID-36965.news.cis.dfn.de>, "mike solomon" <mike.solomon@eps.ltd.uk> posted:
> yes I made a mistake when I put the code here
>
> it should have read
>
> for (@ADD99) {
> if ($_ =~/^[a-z0-9\.\-\_]+@[a-z0-9][a-z0-9\-\.]*\.[a-z]+/I){
this is still a pointless exercise. your regex doesn't work.
> $ADD_GOOD99 = "$ADD_GOOD99 $_";
> }
> else
>
> push @ERROR99 => "INVALID ADDRESS $_";}
> }
>
> the reason I hold an array of bad addresses is that if there is a address
> error, it mails me, and it will still mail to the good addresses if any
>
> the reason I put spaces between the addresses rather than hold them in an
> array is that is the format that MIME Lite expects the address to be in
that still doesn't explain why you have to put "INVALID ADDRESS " in
front of every address in the @ERROR99 array. it's dumb. you
already know every address in there is bad.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Fri, 30 Jun 2000 16:14:42 +0100
From: "mike solomon" <mike.solomon@eps.ltd.uk>
Subject: Re: check for valid e-mail address
Message-Id: <8jidkc$lqo6$1@ID-36965.news.cis.dfn.de>
the regex does what I want it to do
this script is used for reports going to internal addresses and to some of
our customers and it is a lot better than nothing
as to putting INVALID ADDRESS in the array
this is because the array holds other error messages as well as the invalid
addresses , such as invalid file names
I then get mailed with any error messages
brian d foy <brian@smithrenaud.com> wrote in message
news:brian-ya02408000R3006001107400001@news.panix.com...
> In article <8ji440$ktg0$1@ID-36965.news.cis.dfn.de>, "mike solomon"
<mike.solomon@eps.ltd.uk> posted:
>
> > yes I made a mistake when I put the code here
> >
> > it should have read
> >
> > for (@ADD99) {
> > if ($_ =~/^[a-z0-9\.\-\_]+@[a-z0-9][a-z0-9\-\.]*\.[a-z]+/I){
>
> this is still a pointless exercise. your regex doesn't work.
>
> > $ADD_GOOD99 = "$ADD_GOOD99 $_";
> > }
> > else
> >
> > push @ERROR99 => "INVALID ADDRESS $_";}
> > }
> >
> > the reason I hold an array of bad addresses is that if there is a
address
> > error, it mails me, and it will still mail to the good addresses if any
> >
> > the reason I put spaces between the addresses rather than hold them in
an
> > array is that is the format that MIME Lite expects the address to be in
>
> that still doesn't explain why you have to put "INVALID ADDRESS " in
> front of every address in the @ERROR99 array. it's dumb. you
> already know every address in there is bad.
>
> --
> brian d foy
> CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
> Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Fri, 30 Jun 2000 12:11:16 -0500
From: "Barry Grupe" <bg@skypoint.com>
Subject: Re: check for valid e-mail address
Message-Id: <8jikej$2pec$1@shadow.skypoint.net>
"mike solomon" <mike.solomon@eps.ltd.uk> wrote in message
news:8jhqg0$ie20$1@ID-36965.news.cis.dfn.de...
> I have written a script to send e-mail from the Unix command line
>
> I test if what looks like a valid address has been entered and if the
format
> is incorrect I create an error
>
> #test if addresses are valid
> #ADD99 is an array containing addresses
> for (@ADD99) {
> @ADD_NO99 = split("@") ;
> #test if address contains space or field2 does not contain a "."
> if ( $ADD_NO99[0] =~ / / || length($ADD_NO99[0]) == 0 || $ADD_NO99[1]
!~
> /\./ ) {
> push @ERROR99 => "INVALID ADDRESS $_";
> }
> #set up valid addresses
> else { $ADD_GOOD99 = "$ADD_GOOD99 $_"; }
> }
>
> while it works, I am not overly happy with this test, has anyone written a
> better one or is there a module that checks that the format of an e-mail
> address is valid
>
The Perl Cookbook has something to say about this...
quote:
Problem
You want to find a pattern that will verify the validity of a supplied mail
address.
Solution
There isn't one. You cannot do real-time validation of mail addresses. ...
unquote:
Then it goes on to descripe the compromises, one of which refers to a
ckaddr.gz file at CPAN that attempts to validate by checking the RFC-822
regexp (in Mastering Regular Expressions from O'Reilly), DNS MX record
look-up, etc. Dunno about Abigal's module, but it's likely just as valid.
I've been using a regexp to allow alphanumeric, and dash/dot/underscore, but
there are legit addresses that use more than these characters. (I think I've
even seen mention of *@somedomain.xxx in this newsgroup).
Anyhoo,
if(/^[a-z0-9][a-z0-9]*(?:[\-\._][a-z0-9]+)*\@[a-z0-9]+(?:[\-\.][a-z0-9]+)*\.
[a-z]{2,3}/) {
#valid address;
} else {
&error;
}
Hope this helps...
------------------------------
Date: Fri, 30 Jun 2000 15:10:24 GMT
From: James Fisher <jfisher@epotec.com>
Subject: comparison question
Message-Id: <395CB819.93F00670@epotec.com>
I am using the following code in an if statement
if ($element eq "QUESTION" && $_{'NUMBER'} == $SearchNumber) {
The latter comparison is failing when comparing two variables. I know
you can compare variables... I have tried using eval to get a result to
no avail. Possibly, is it the module I am using(XML::Parser module).
JF
------------------------------
Date: Fri, 30 Jun 2000 15:14:14 GMT
From: manchester_united@my-deja.com
Subject: Re: correct name space
Message-Id: <8jidfj$bke$1@nnrp1.deja.com>
In article <8jhsj5$v1o$1@nnrp1.deja.com>,
eastking@my-deja.com wrote:
> Hi ,every one here.
>
> I have written a pm file and two pl script as following
>
> commonuse.pl
>
> sub test(){
> # so sth here
> }
> 1;
>
> Init.pm
>
> package Init;
>
> require "commonuse.pl";
>
> sub new(){
> #do bless and others
> test();
> #do other things
> }
> 1;
>
> testscript.pl
>
> use Init;
> require "commonuse.pl";
>
> my $Init = Init->new();
>
> test();
>
> when I run "perl test.pl", it said " Undefined subroutine &main::test
> called at testscript.pl line 6."
>
> Why does not Perl find correct name space? Thanks in advance.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Unlikely, but.....
Make sure you have saved all files, and that the file 'testscript.pl'
is in the same folder as the 'commonuse.pl' prog. PERL checks its own
folder paths for modules, plus the execution path i.e. the path that is
running 'commonuse.pl'.
It's about as sophistocated a suggestion you'll get out of me on a
Friday afternoon! Good luck.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 30 Jun 2000 12:44:11 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: correct name space
Message-Id: <Pine.GSO.4.21.0006301238190.7544-100000@crusoe.crusoe.net>
On Jun 30, manchester_united@my-deja.com said:
>> # commonuse.pl
>> sub test(){
>> # so sth here
>> }
>> 1;
First, I don't think you want those () after your function
declarations. Those are prototypes, and you don't want them (unless
there's something you're not telling us).
>> # Init.pm
>> package Init;
>> require "commonuse.pl";
>> sub new(){
>> test();
>> }
>> 1;
>> # testscript.pl
>> use Init;
>> require "commonuse.pl";
>> my $Init = Init->new();
>> test();
>> when I run "perl test.pl", it said " Undefined subroutine &main::test
>> called at testscript.pl line 6."
require() only includes the file ONCE. If a file has already been
require()d, require() won't include it again. Therefore, the FIRST time
commonuse.pl is require()d, the test() function is Init::test(). The
second time, when you TRY to require() it again, nothing happens. Thus,
test() is never placed in main::. Some workarounds:
* use do() instead of require()
do "commonuse.pl" or die "error: $!";
* localize %INC
# in Init.pm
package Init;
local %INC = %INC;
require "commonuse.pl";
# in testscript.pl
use Init;
require "commonuse.pl";
* put test() in the UNIVERSAL:: package (LAST RESORT)
sub UNIVERSAL::test { ... }
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
------------------------------
Date: Fri, 30 Jun 2000 15:41:31 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: DBI and interpolation
Message-Id: <Lc375.758$iP2.75464@news.dircon.co.uk>
On Fri, 30 Jun 2000 09:06:53 GMT, Prasanth A. Kumar Wrote:
>
> I have a perl script which makes use of DBI to query/update a
> database. One problem is that if some the query variables, which are
> interpolated into the prepare statement have single quotes in them,
> the query fails. So is the proper solution to use '?' in place of the
> interpolations and then do bind_param's?
>
Yes.
/J\
------------------------------
Date: Fri, 30 Jun 2000 11:23:34 -0400
From: "James M Kupernik" <kupernik@bcn.net>
Subject: Debugger Command
Message-Id: <slpf0iunjev47@corp.supernews.com>
I am trying to run my program but the debugger keeps comming up with this
program in my program. To my understand it is saying that } is missing from
the end of my script, but it is there. I copied the message below, what else
does it mean??
Missing right bracket at quickorder.cgi line 886, at end of line
(Might be a runaway multi-line << string starting on line 882)
syntax error at quickorder.cgi line 886, at EOF
Thanks,
James
------------------------------
Date: Fri, 30 Jun 2000 16:28:07 +0100
From: "mike solomon" <mike.solomon@eps.ltd.uk>
Subject: Re: Debugger Command
Message-Id: <8jied9$mh2j$1@ID-36965.news.cis.dfn.de>
check all your { are matched
Regards
Mike Solomon
James M Kupernik <kupernik@bcn.net> wrote in message
news:slpf0iunjev47@corp.supernews.com...
> I am trying to run my program but the debugger keeps comming up with this
> program in my program. To my understand it is saying that } is missing
from
> the end of my script, but it is there. I copied the message below, what
else
> does it mean??
>
> Missing right bracket at quickorder.cgi line 886, at end of line
> (Might be a runaway multi-line << string starting on line 882)
> syntax error at quickorder.cgi line 886, at EOF
>
>
> Thanks,
> James
>
>
------------------------------
Date: 30 Jun 2000 10:35:15 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Finding FatalsToEmail ?
Message-Id: <m13dlvjcmk.fsf@halfdome.holdit.com>
>>>>> "Jukka" == Jukka Juslin <jtjuslin@kosh.hut.fi> writes:
Jukka> I heard from Randal L. Schwarz about FatalsToEmail, but could not find it
Jukka> with altavista or google. Where can I get such a thing?
It's for an upcoming Linux Magazine article. It'll show up on their
website at www.linuxmagazine.com after it's published, or on my
website at http://www.stonehenge.com/merlyn/LinuxMag/ about three
months after that.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Fri, 30 Jun 2000 11:25:59 -0500
From: Joe Digilio <jdigil1@uic.edu>
Subject: formatting output of a process
Message-Id: <Pine.GSO.4.10.10006301110440.24577-100000@icarus.cc.uic.edu>
Hello all-
I'm stumped. Here's the situation:
I am writing a perl script to automate building a project (running make).
I need to redirect the output to one file. The problem is, all output from
the make command must be stored to the file in the following format:
YYYY-MM-DD HH:MM:SS [ERR|OUT]: <output line>
Where the date/time is the time of the line's output.
One more caveat: it has to be in the same order as it was originally
output.
I have tried opening pipes, redirecting output, etc to no avail.
Anyone have any ideas?
Thanks much!
-Joe
------------------------------
Date: Fri, 30 Jun 2000 11:39:53 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Help with hashes
Message-Id: <395CBF49.9C3C03B3@attglobal.net>
Tad McClellan wrote:
>
>
> I'll still be calling her "Mrs. Wall" years from now...
>
I'm still at the point where when she walks right by me, I think to
myself "Was that Mr. Wall's wife? huh"
------------------------------
Date: Fri, 30 Jun 2000 08:23:14 -0600
From: "Colby Hansen" <cghansen@micron.com>
Subject: Re: Help with hashes
Message-Id: <8jiagj$3i0$1@admin-srv3.micron.com>
>Do you claim that it is not a waste of time to review code
>that does not exist?
>I am not getting your point.
I assure you the code does exist and it did when I posted my original
message. My point is that so what if I made two typos... my question was
answered, my code works now, and I even learned some things (hey, maybe
other people reading this newsgroup did too). Isn't that the point... I
doubt the point is to see who is proficient at copying and pasting their
code.
>Do young people not mind wasting time, and old people do?
Probably...
>Or do old people not mind wasting time, and young people do?
Probably true also...
------------------------------
Date: Fri, 30 Jun 2000 16:50:52 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: Help with hashes
Message-Id: <Md475.2468$k5.49283@news1.rdc1.mb.home.com>
In article <8jiagj$3i0$1@admin-srv3.micron.com>,
Colby Hansen <cghansen@micron.com> wrote:
[snip]
> I assure you the code does exist and it did when I posted my original
> message. My point is that so what if I made two typos... my question was
> answered, my code works now, and I even learned some things (hey, maybe
> other people reading this newsgroup did too). Isn't that the point... I
> doubt the point is to see who is proficient at copying and pasting their
> code.
You are right, that isn't the point -- nor was it Tad's point. When
you pasted in your code and then realized you left some out and
decided to just type that part in you made a mistake (typing in code
instead of pasting the real thing) resulting in two more errors (the
typos).
Tad admonished you for that -- and rightly so. No one wants to waste
time debugging code that isn't really code you intended, nor trying
figure out where your real problem lies (if the first two lines have
typos, what other un-intended mistakes exist in this code and how can
I tell which mistakes are typos and which are part of the problem?).
I am glad you were able to learn something as a result of your
message, and I sincerely hope that one of things you learned was as
result of Tad's advice: do not retype code you want help with -- not
even two lines of it. I certainly do not think his response was
offensive, nor intended to be offensive -- just a Tad smart-ass :-)
andrew
--
Andrew L. Johnson http://members.home.net/perl-epwp/
In theory, there's no difference between
theory and practice, but in practice there is!
------------------------------
Date: Fri, 30 Jun 2000 10:36:05 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: how do i create an array of hashes?
Message-Id: <slrn8lpc2l.696.tadmc@magna.metronet.com>
On Fri, 30 Jun 2000 14:55:07 +0200, TheEx0rcist <TheEx0rcist@fanclub.org> wrote:
>> ------------------
>> #!/usr/bin/perl -w
>> use strict;
>> use Data::Dumper;
>>
>> my $ref_to_LoH = [ { } ];
>>
>> print Dumper $ref_to_LoH;
>> ------------------
>
>
>??????????????
That code "creates an array of hashes", and uses Data::Dumper
to show that it has created an array of hashes.
It is the most direct answer to the the question you asked.
Perhaps you should have asked a different question?
I did not populate any of the elements because you did not
give any info on how you need them populated.
A poor specification yields a poor implementation
(lesson: take care when crafting your specification).
I expect that you have already perldoc'd all of the below?
If not, you will need to read at least some of them to
understand what you are doing (making a multi-level data structure)
perlreftut references tutorial
perlref references reference :-)
perllol Lists of Lists, easily modified into LoH
perldsc Data Structures Cookbook
Here is a LoH that has some (made up) data in it:
--------------------------
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
# values show how to access the data structure
my $ref_to_LoH = [ { key1 => '$ref_to_LoH->[0]{key1}' },
{ key2 => '$ref_to_LoH->[1]{key2}',
key3 => '$ref_to_LoH->[1]{key3}'
}
];
print "$ref_to_LoH->[0]{key1}\n"; # access them individually
print "$ref_to_LoH->[1]{key2}\n";
print "$ref_to_LoH->[1]{key3}\n\n";
print Dumper $ref_to_LoH; # show the entire data structure
--------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
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 3524
**************************************