[16168] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3580 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 10 17:48:39 2000

Date: Mon, 10 Jul 2000 14:48:16 -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: <963265696-v9-i3580@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 10 Jul 2000     Volume: 9 Number: 3580

Today's topics:
        modules from www.activestate.com for WindowsNT <popp@in.tum.de>
    Re: modules from www.activestate.com for WindowsNT <dko@berlin.snafu.de>
    Re: modules from www.activestate.com for WindowsNT <randy@theory.uwinnipeg.ca>
    Re: modules from www.activestate.com for WindowsNT <newsboy@realbasics.com>
    Re: modules from www.activestate.com for WindowsNT (Francis T. Lee)
    Re: modules from www.activestate.com for WindowsNT <randy@theoryx5.uwinnipeg.ca>
    Re: modules from www.activestate.com for WindowsNT (Francis T. Lee)
    Re: modules from www.activestate.com for WindowsNT <randy@theory.uwinnipeg.ca>
    Re: modules from www.activestate.com for WindowsNT (Reini Urban)
        Multidimensional arrays <astro@shell.athenet.net>
    Re: Multidimensional arrays <stephenk@cc.gatech.edu>
    Re: Multidimensional arrays (Keith Calvert Ivey)
    Re: Multidimensional arrays <bwalton@rochester.rr.com>
    Re: Multidimensional arrays <astro@shell.athenet.net>
    Re: Multidimensional arrays <astro@shell.athenet.net>
    Re: Multidimensional arrays <stephenk@cc.gatech.edu>
    Re: Multidimensional arrays <bwalton@rochester.rr.com>
    Re: Multidimensional arrays <astro@shell.athenet.net>
    Re: Multidimensional arrays (Keith Calvert Ivey)
    Re: Multidimensional arrays <iltzu@sci.invalid>
        multidimensional associative arrays <phil.rennert@ioip.com>
    Re: multidimensional associative arrays <aqumsieh@hyperchip.com>
    Re: multidimensional associative arrays <phil.rennert@ioip.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 06 Jul 2000 22:39:38 +0200
From: Gerhard Popp <popp@in.tum.de>
Subject: modules from www.activestate.com for WindowsNT
Message-Id: <3964EE89.ADAE143F@in.tum.de>

Hello,

I downloaded a up to date version of perl from www.activate.com.
Furtermore I downloaded some Modules, e.g DBI.zip, Win32-ODBC.zip,...
After I had extracted the zip-files, I wanted to install the ppd-modules.

Now my problem:
How could I install this module packages with my Perl Packet Manager
unter WinNT bzw. Win2000?
If I start the ppm with e.g.

    ppm install Win32-ODBC.ppd
    (Win32-ODBC is in the current directory)

I got the following error-message:

    Error installing package 'Win32-ODBC.ppd': Could not locate a PPM
    binary of Win32-ODBC.ppd for this platform.

I know, there are several binary for different platforms, but Win32-ODBC
doesn't work under NT4.0 or Win2000 too.

Knows anybody a solution for this problem or a server, where I could get
a other perl-distribution, which is complete or easier to install?

Greetings,
    Gerhard






------------------------------

Date: 6 Jul 2000 20:51:41 GMT
From: "dko" <dko@berlin.snafu.de>
Subject: Re: modules from www.activestate.com for WindowsNT
Message-Id: <01bfe78c$37319fe0$1800a8c0@maurice>

For some Modules you'll need Microsofts  nmake15.exe 
but that produces also undefined errors.

Microsoft doesn´t like Perl,
and ActivState throws everything to Microsoft.

Does anybody know how to install CPAN-Libs on NT ??
Regards Dietmar


Gerhard Popp <popp@in.tum.de> schrieb im Beitrag
<3964EE89.ADAE143F@in.tum.de>...
> Hello,
> 
> I downloaded a up to date version of perl from www.activate.com.
> Furtermore I downloaded some Modules, e.g DBI.zip, Win32-ODBC.zip,...
> After I had extracted the zip-files, I wanted to install the ppd-modules.
> 
> Now my problem:
> How could I install this module packages with my Perl Packet Manager
> unter WinNT bzw. Win2000?
> If I start the ppm with e.g.
> 
>     ppm install Win32-ODBC.ppd
>     (Win32-ODBC is in the current directory)
> 
> I got the following error-message:
> 
>     Error installing package 'Win32-ODBC.ppd': Could not locate a PPM
>     binary of Win32-ODBC.ppd for this platform.
> 
> I know, there are several binary for different platforms, but Win32-ODBC
> doesn't work under NT4.0 or Win2000 too.
> 
> Knows anybody a solution for this problem or a server, where I could get
> a other perl-distribution, which is complete or easier to install?
> 
> Greetings,
>     Gerhard
> 
> 
> 
> 
> 


------------------------------

Date: Thu, 6 Jul 2000 18:13:55 -0500
From: "Randy Kobes" <randy@theory.uwinnipeg.ca>
Subject: Re: modules from www.activestate.com for WindowsNT
Message-Id: <8k340a$a53$1@canopus.cc.umanitoba.ca>


dko <dko@berlin.snafu.de> wrote in
    message news:01bfe78c$37319fe0$1800a8c0@maurice...
 [ ... ]
> For some Modules you'll need Microsofts  nmake15.exe
> but that produces also undefined errors.

For modules not available through ActiveState's ppm
utility you do need a make program, but nmake works
well for many people. Errors would result if things weren't
configured properly, but that's true of anything ...

> Microsoft doesn´t like Perl,
> and ActivState throws everything to Microsoft.

Search dejanews for responses to this ...

> Does anybody know how to install CPAN-Libs on NT ??

What I did was get nmake from
ftp://ftp.microsoft.com/softlib/MSLFILES/nmake15.exe
(or from VC++, if you have that), make sure that's
set up properly, then fire up the CPAN.pm module:
    perl -MCPAN -e shell
After that's configured, it's a relative breeze
to install modules .... Or you can do things
manually, as discussed in
'perldoc perlmodinstall'.

best regards,
randy kobes





------------------------------

Date: Thu, 6 Jul 2000 17:12:41 -0700
From: "David Innes" <newsboy@realbasics.com>
Subject: Re: modules from www.activestate.com for WindowsNT
Message-Id: <Aab95.434$R8.306383@news.uswest.net>

Conspiracy theories notwithstanding it's probably best to first download the
PPM hot fix for the latest Perl version.  Here's what ActiveState says on
it's Perl download page:
http://www.activestate.com/Products/ActivePerl/Download.html

"PPM Hotfix!
There are problems with the version of PPM that shipped with the above
packages [version 5.6, release 613, ed]. To correct these problems, download
the Windows version (http://www.activestate.com/PPM/fixes/ppmfix.zip) of the
hotfix and follow the instructions contained in the README file. Be sure to
install this as soon as ActivePerl is installed, not on an existing
installation. Linux and Solaris versions of the hotfix will be available
soon."

Once I installed the PPM patch I could download modules.
        -- David Innes

"dko" <dko@berlin.snafu.de> wrote in message
news:01bfe78c$37319fe0$1800a8c0@maurice...
> For some Modules you'll need Microsofts  nmake15.exe
> but that produces also undefined errors.
>
> Microsoft doesn´t like Perl,
> and ActivState throws everything to Microsoft.
>
> Does anybody know how to install CPAN-Libs on NT ??
> Regards Dietmar
>
>
> Gerhard Popp <popp@in.tum.de> schrieb im Beitrag
> <3964EE89.ADAE143F@in.tum.de>...
> > Hello,
> >
> > I downloaded a up to date version of perl from www.activate.com.
> > Furtermore I downloaded some Modules, e.g DBI.zip, Win32-ODBC.zip,...
> > After I had extracted the zip-files, I wanted to install the
ppd-modules.
> >
> > Now my problem:
> > How could I install this module packages with my Perl Packet Manager
> > unter WinNT bzw. Win2000?
> > If I start the ppm with e.g.
> >
> >     ppm install Win32-ODBC.ppd
> >     (Win32-ODBC is in the current directory)
> >
> > I got the following error-message:
> >
> >     Error installing package 'Win32-ODBC.ppd': Could not locate a PPM
> >     binary of Win32-ODBC.ppd for this platform.
> >
> > I know, there are several binary for different platforms, but Win32-ODBC
> > doesn't work under NT4.0 or Win2000 too.
> >
> > Knows anybody a solution for this problem or a server, where I could get
> > a other perl-distribution, which is complete or easier to install?
> >
> > Greetings,
> >     Gerhard
> >
> >
> >
> >
> >




------------------------------

Date: 7 Jul 2000 09:13:58 -0400
From: francis@umbc.edu (Francis T. Lee)
Subject: Re: modules from www.activestate.com for WindowsNT
Message-Id: <8k4l2m$53qv$1@everest.cs.umbc.edu>

In article <8k340a$a53$1@canopus.cc.umanitoba.ca>,
Randy Kobes <randy@theory.uwinnipeg.ca> wrote:
>
>
>What I did was get nmake from
>ftp://ftp.microsoft.com/softlib/MSLFILES/nmake15.exe
>(or from VC++, if you have that), make sure that's
>set up properly, then fire up the CPAN.pm module:
>    perl -MCPAN -e shell
>After that's configured, it's a relative breeze
>to install modules .... Or you can do things
>manually, as discussed in
>'perldoc perlmodinstall'.
>
>best regards,
>randy kobes
>
>
>

Randy -

Thanks for answering my "other" question regarding installing MD5.pm!

While we're still on this subject, I'm wondering if we need C (or C++)
compilers in order to compile/install some of the modules (which comes in
the .tar.gz format) on NT? 

As you can probably tell that I'm really green on this...  what's the
"cl" stands for in the "cc=" line in config.pm?

Thanks again!!  :-)

	-francis



------------------------------

Date: 7 Jul 2000 14:05:03 GMT
From: Randy Kobes <randy@theoryx5.uwinnipeg.ca>
Subject: Re: modules from www.activestate.com for WindowsNT
Message-Id: <8k4o2f$2qo$1@canopus.cc.umanitoba.ca>

In comp.lang.perl.misc Francis T. Lee <francis@umbc.edu> wrote:
[ ... ]
> While we're still on this subject, I'm wondering if we need C (or C++)
> compilers in order to compile/install some of the modules (which comes in
> the .tar.gz format) on NT? 

> As you can probably tell that I'm really green on this...  what's the
> "cl" stands for in the "cc=" line in config.pm?

Hi,
    For some modules you do need a C compiler - for 
binary compatability, you should use the same one
that Perl was compiled with. Digest::MD5 is an example
of a module that needs one. The "cl" in "cc=" in Config.pm
stands for Microsoft's VC++ compiler, cl.exe - this is
the one that ActiveState uses. If you want to set up
things to use your compiler, you may also need to change
in Config.pm the paths to the system lib and include
files, to reflect where they are on your system.

best regards,
randy kobes


------------------------------

Date: 7 Jul 2000 10:24:06 -0400
From: francis@umbc.edu (Francis T. Lee)
Subject: Re: modules from www.activestate.com for WindowsNT
Message-Id: <8k4p66$54v0$1@everest.cs.umbc.edu>

In article <8k4o2f$2qo$1@canopus.cc.umanitoba.ca>,
Randy Kobes  <randy@theoryx5.uwinnipeg.ca> wrote:
>In comp.lang.perl.misc Francis T. Lee <francis@umbc.edu> wrote:
>[ ... ]
>> While we're still on this subject, I'm wondering if we need C (or C++)
>> compilers in order to compile/install some of the modules (which comes in
>> the .tar.gz format) on NT? 
>
>> As you can probably tell that I'm really green on this...  what's the
>> "cl" stands for in the "cc=" line in config.pm?
>
>Hi,
>    For some modules you do need a C compiler - for 
>binary compatability, you should use the same one
>that Perl was compiled with. 

	So it'll be a good idea to get the source of ActiveState Perl
	and compile it with BCC5.5 that I have, right?  Or I can just 
	do what you suggested below that simply modify the paths
	to the includes and libs in Config.pm?

	Thanks!!  :-)

		-francis
	
>Digest::MD5 is an example
>of a module that needs one. The "cl" in "cc=" in Config.pm
>stands for Microsoft's VC++ compiler, cl.exe - this is
>the one that ActiveState uses. If you want to set up
>things to use your compiler, you may also need to change
>in Config.pm the paths to the system lib and include
>files, to reflect where they are on your system.
>




------------------------------

Date: Fri, 7 Jul 2000 19:37:19 -0500
From: "Randy Kobes" <randy@theory.uwinnipeg.ca>
Subject: Re: modules from www.activestate.com for WindowsNT
Message-Id: <8k5t8n$jc1$1@canopus.cc.umanitoba.ca>


Francis T. Lee <francis@umbc.edu> wrote in
    message news:8k4p66$54v0$1@everest.cs.umbc.edu...
> In article <8k4o2f$2qo$1@canopus.cc.umanitoba.ca>,
> Randy Kobes  <randy@theoryx5.uwinnipeg.ca> wrote:
[ ... ]
> >    For some modules you do need a C compiler - for
> >binary compatability, you should use the same one
> >that Perl was compiled with.
>
> So it'll be a good idea to get the source of ActiveState Perl
> and compile it with BCC5.5 that I have, right?  Or I can just
> do what you suggested below that simply modify the paths
> to the includes and libs in Config.pm?

Not knowing how well VC++ and BCC work
together, my inclination would be to start from
scratch and compile your own perl, and stick
with the same compiler throughout. I haven't
done so with BCC, but Perl-5.6.0 compiles
quite readily with VC++. However, it would
be straightforward to test things out if BCC and
ActiveState's perl can cooperate - change the
cc=... and make=... lines in Config.pm,
adjust the paths to the libs and includes
accordingly, and then build and test some
XS modules like Digest::MD5 that need a
C compiler. If you do go this route,
I'm sure there'd be a good number of people
in this group who would be interested in
your experiences (good or bad).

best regards,
randy kobes






------------------------------

Date: Sat, 08 Jul 2000 15:11:31 GMT
From: rurban@sbox.tu-graz.ac.at (Reini Urban)
Subject: Re: modules from www.activestate.com for WindowsNT
Message-Id: <396743fe.12282471@news>

dko wrote:
>For some Modules you'll need Microsofts  nmake15.exe 
>but that produces also undefined errors.
>
>Microsoft doesn´t like Perl,

not true. 
it just doesn't fit into their niche and would harm their language
business.

>and ActivState throws everything to Microsoft.

not true. they help themselves.

>Does anybody know how to install CPAN-Libs on NT ??
>Regards Dietmar

yes, if the ActiveState pre-compiled binaries won't work, do it by
yourself.
read README and INSTALL.
--                                         
Reini


------------------------------

Date: Thu, 6 Jul 2000 20:44:44 -0500
From: "John Coke" <astro@shell.athenet.net>
Subject: Multidimensional arrays
Message-Id: <ACa95.1897$ef3.591313@homer.alpha.net>

My friend has a perl question I was unable to answer so I thought I'd throw
it up here for him.

He has a 3-dimensional array in the format of {hash}[array]{hash}. He would
like to get the number of array elements for a paticular hash... ie
$this{'foo'}. How can this be done?

Also, why can foreach not be used in this context? IE...

    foreach %hash (@{$this{'test'}) { }

I understand the implications of using 'this' as a variable name, so don't
whine about that, it's just an example =)

-John





------------------------------

Date: Thu, 06 Jul 2000 23:19:54 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: Multidimensional arrays
Message-Id: <39654C5A.FF1F0BBB@cc.gatech.edu>

John Coke wrote:

> He has a 3-dimensional array in the format of {hash}[array]{hash}. He would
> like to get the number of array elements for a paticular hash... ie
> $this{'foo'}. How can this be done?
>

Ever read perllol?  Although the examples are strictly arrays, the same
concepts apply to hashes.
Recall that arrays and hashes store scalars, not arrays or hashes, so scalar
references are used instead.  Therefore, the correct dereferencing syntax would
be $myhash{$index1}->[$index2]->{$index3};
Getting the size of $myhash{$index} is simply of dereferencing the array and
evaluating in scalar context: $size = @{$myhash{$index}};


>
> Also, why can foreach not be used in this context? IE...
>
>     foreach %hash (@{$this{'test'}) { }
>

As stated above, array and hash entries are scalars.  Use $hash instead.

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




------------------------------

Date: Fri, 07 Jul 2000 03:35:06 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Multidimensional arrays
Message-Id: <39694e6e.3696899@nntp.idsonline.com>

"John Coke" <astro@shell.athenet.net> wrote:

>He has a 3-dimensional array in the format of {hash}[array]{hash}. He would
>like to get the number of array elements for a paticular hash... ie
>$this{'foo'}. How can this be done?

If $this{'foo'} (or $this{foo} -- the quotes aren't needed
around a bareword in braces) is an array reference, then the
number of elements in the array can be determined as with any
other array, by putting it in a scalar context:

    $number = @{$this{foo}};

>Also, why can foreach not be used in this context? IE...
>
>    foreach %hash (@{$this{'test'}) { }

Because the elements of the array, like those of any array, are
scalars.  It's not an array of hashes, though people sometimes
might speak of it loosely that way; it's an array of hash
*references*.  You need to use a scalar variable

    foreach $hash_ref (@{$this{test}) { }

and then write, for example $hash_ref->{key} instead of
$hash{key}.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


------------------------------

Date: Fri, 07 Jul 2000 03:41:03 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Multidimensional arrays
Message-Id: <39655193.803E4456@rochester.rr.com>

John Coke wrote:
> 
> My friend has a perl question I was unable to answer so I thought I'd throw
> it up here for him.
> 
> He has a 3-dimensional array in the format of {hash}[array]{hash}. He would
> like to get the number of array elements for a paticular hash... ie
> $this{'foo'}. How can this be done?

Try:  $count=@{$this{foo}};

> 
> Also, why can foreach not be used in this context? IE...
> 
>     foreach %hash (@{$this{'test'}) { }

It can, but your index variable must be a scalar, which will hold the
hash references that are stored in the array.  Like:

      foreach $hashref (@{$this{test}){...}

> 
> I understand the implications of using 'this' as a variable name, so don't
> whine about that, it's just an example =)

What implications?  'this' is no different than any other non-special
variable name in Perl.

> 
> -John
-- 
Bob Walton


------------------------------

Date: Thu, 6 Jul 2000 22:50:38 -0500
From: "John Coke" <astro@shell.athenet.net>
Subject: Re: Multidimensional arrays
Message-Id: <Dsc95.1937$ef3.596155@homer.alpha.net>

Since all the messages were incorrect, I replied to my original post...

I tried your suggestions earlier...
    $count = @{ $dme_tie_list{ $tie_noun } };
 ... and came up with an odd result. Instead of printing the number of array
elements, it prints a total of all the hash values.

Each hash has three keys... ie
$dme_tie_list{'foo'}[0]{'one'}, $dme_tie_list{'foo'}[0]{'two'},
$dme_tie_list{'foo'}[0]{'three'}

-John

John Coke <astro@shell.athenet.net> wrote in message
news:ACa95.1897$ef3.591313@homer.alpha.net...
> My friend has a perl question I was unable to answer so I thought I'd
throw
> it up here for him.
>
> He has a 3-dimensional array in the format of {hash}[array]{hash}. He
would
> like to get the number of array elements for a paticular hash... ie
> $this{'foo'}. How can this be done?
>
> Also, why can foreach not be used in this context? IE...
>
>     foreach %hash (@{$this{'test'}) { }
>
> I understand the implications of using 'this' as a variable name, so don't
> whine about that, it's just an example =)
>
> -John
>
>
>




------------------------------

Date: Thu, 6 Jul 2000 22:54:01 -0500
From: "John Coke" <astro@shell.athenet.net>
Subject: Re: Multidimensional arrays
Message-Id: <Ovc95.1939$ef3.596260@homer.alpha.net>

Actually, to provide more information. I attempted the following:

    print "Starting count is " . @{$dme_tie_list{$tie_noun}} . "\n";
    push @{$dme_tie_list{$tie_noun}}, %tie;
    print "Ending count is " . @{$dme_tie_list{$tie_noun}} . "\n";

Each iteration, the starting count is (undef) and the end count is 6. There
are 3 hash keys being set in $tie before it is pushed.

-John

Bob Walton <bwalton@rochester.rr.com> wrote in message
news:39655193.803E4456@rochester.rr.com...
> John Coke wrote:
> >
> > My friend has a perl question I was unable to answer so I thought I'd
throw
> > it up here for him.
> >
> > He has a 3-dimensional array in the format of {hash}[array]{hash}. He
would
> > like to get the number of array elements for a paticular hash... ie
> > $this{'foo'}. How can this be done?
>
> Try:  $count=@{$this{foo}};
>
> >
> > Also, why can foreach not be used in this context? IE...
> >
> >     foreach %hash (@{$this{'test'}) { }
>
> It can, but your index variable must be a scalar, which will hold the
> hash references that are stored in the array.  Like:
>
>       foreach $hashref (@{$this{test}){...}
>
> >
> > I understand the implications of using 'this' as a variable name, so
don't
> > whine about that, it's just an example =)
>
> What implications?  'this' is no different than any other non-special
> variable name in Perl.
>
> >
> > -John
> --
> Bob Walton




------------------------------

Date: Fri, 07 Jul 2000 00:34:28 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: Multidimensional arrays
Message-Id: <39655DD4.66A4B418@cc.gatech.edu>

John Coke wrote:

> Actually, to provide more information. I attempted the following:
>
>     print "Starting count is " . @{$dme_tie_list{$tie_noun}} . "\n";
>     push @{$dme_tie_list{$tie_noun}}, %tie;
>     print "Ending count is " . @{$dme_tie_list{$tie_noun}} . "\n";
>
> Each iteration, the starting count is (undef) and the end count is 6. There
> are 3 hash keys being set in $tie before it is pushed.
>

You are appending the contents of  hash (evaluated in list context) to the end
of an array, namely $dme_tie_list{$tie_noun}.  The result is that the array now
contains ['key1', 'val1', 'key2', 'val2', 'key3', 'val3'], which has a length
of 6.  Your other posts imply you wanted the has to show up inside
$dme_tie_list{$tie_noun}[0].  The correct syntax for that is
push @{$dme_tie_list{$tie_noun}}, \%tie;
After this line, scalar @{$dme_tie_list{$tie_noun}} will return 1, which
answers your question.  If you wanted to know how many keys are in a specific
array entry (instead of vice versa, as you had originally stated), the correct
syntax is scalar keys %{$dme_tie_list{$tie_noun}[$index]}.

I recommend you read perldata, perlref, and perllol.

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




------------------------------

Date: Fri, 07 Jul 2000 04:42:10 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Multidimensional arrays
Message-Id: <39655FE5.E175993C@rochester.rr.com>

John Coke wrote:
> 
> Actually, to provide more information. I attempted the following:
> 
>     print "Starting count is " . @{$dme_tie_list{$tie_noun}} . "\n";
>     push @{$dme_tie_list{$tie_noun}}, %tie;
>     print "Ending count is " . @{$dme_tie_list{$tie_noun}} . "\n";
> 
> Each iteration, the starting count is (undef) and the end count is 6. There
> are 3 hash keys being set in $tie before it is pushed.

Yes, so it got the count right.  Are you sure you want to push the hash
onto the array, though?  A hash with three keys evaluated in list
context will generate a six-element list, which is then pushed; hence
your count of 6.  You probably want to push a reference to the hash, as
in:

      push @{$dme_tie_list{$tie_noun}}, \%tie;

> 
> -John
 ...
-- 
Bob Walton


------------------------------

Date: Thu, 6 Jul 2000 23:48:29 -0500
From: "John Coke" <astro@shell.athenet.net>
Subject: Re: Multidimensional arrays
Message-Id: <Sid95.1953$ef3.597746@homer.alpha.net>

To both bob and stephen...

Thanks alot. this really helped my friend, and taught me some things in the
process :)

-John

Bob Walton <bwalton@rochester.rr.com> wrote in message
news:39655FE5.E175993C@rochester.rr.com...
> John Coke wrote:
> >
> > Actually, to provide more information. I attempted the following:
> >
> >     print "Starting count is " . @{$dme_tie_list{$tie_noun}} . "\n";
> >     push @{$dme_tie_list{$tie_noun}}, %tie;
> >     print "Ending count is " . @{$dme_tie_list{$tie_noun}} . "\n";
> >
> > Each iteration, the starting count is (undef) and the end count is 6.
There
> > are 3 hash keys being set in $tie before it is pushed.
>
> Yes, so it got the count right.  Are you sure you want to push the hash
> onto the array, though?  A hash with three keys evaluated in list
> context will generate a six-element list, which is then pushed; hence
> your count of 6.  You probably want to push a reference to the hash, as
> in:
>
>       push @{$dme_tie_list{$tie_noun}}, \%tie;
>
> >
> > -John
> ...
> --
> Bob Walton




------------------------------

Date: Fri, 07 Jul 2000 04:54:42 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Multidimensional arrays
Message-Id: <396560e6.8425067@nntp.idsonline.com>

"John Coke" <astro@shell.athenet.net> wrote:

>Since all the messages were incorrect, I replied to my original post...
>
>I tried your suggestions earlier...
>    $count = @{ $dme_tie_list{ $tie_noun } };
>... and came up with an odd result. Instead of printing the number of array
>elements, it prints a total of all the hash values.

I'm sorry that you think all the replies were incorrect, but
$count is indeed the number of array elements.  It may not be
what you think the number of array elements is, but that's
probably because you're constructing the array incorrectly
(perhaps by confusing hash references and hashes).

Please at least consider the possibility that *you* are the one
who is incorrect -- not all the people trying to help you (most
of whom seem to understand references much better than you do).

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


------------------------------

Date: 7 Jul 2000 10:51:06 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Multidimensional arrays
Message-Id: <962966400.1922@itz.pp.sci.fi>

In article <Dsc95.1937$ef3.596155@homer.alpha.net>, John Coke wrote:
>Since all the messages were incorrect, I replied to my original post...

 ..and if you're driving along the highway and there's a warning on the
radio about someone driving on the wrong side of the road, do you also
think: "What do they mean, just one?  There must be hundreds of them!"


>I tried your suggestions earlier...
>    $count = @{ $dme_tie_list{ $tie_noun } };

This is perfectly correct.  If it does not produce the answer you
expect, it means that your data structure does not contain what you
expect.  The easiest way to see what your data structure actually does
contain is using Data::Dumper.

  use Data::Dumper;
  print Dumper(\%dme_tie_list);

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.




------------------------------

Date: Mon, 10 Jul 2000 10:37:25 -0400
From: Philip Rennert <phil.rennert@ioip.com>
Subject: multidimensional associative arrays
Message-Id: <3969DFA5.B7BE6B5E@ioip.com>

When I have a multidimensional array, it's easy to fix one index and
iterate on another:

for($j=1;$j<=$n;$j++)
    {

    code involving $a[6][$j]

    }

but what's a good way to do that with associative arrays, other than the
kludgey:

foreach( keys %a)
    {
    if not (/^Fred/){next}

    code involving $a{$_}  to deal with only elements of the form
$a{"Fred"}{whatever}

(also this assumes "Fred" doesn't occur in another index or in longer
form in the first)

    }



------------------------------

Date: Mon, 10 Jul 2000 15:25:21 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: multidimensional associative arrays
Message-Id: <7aaefqknwd.fsf@merlin.hyperchip.com>


Philip Rennert <phil.rennert@ioip.com> writes:

> When I have a multidimensional array, it's easy to fix one index and
> iterate on another:
> 
> for($j=1;$j<=$n;$j++)
>     {
> 
>     code involving $a[6][$j]
> 
>     }
> 
> but what's a good way to do that with associative arrays, other than the
> kludgey:
> 
> foreach( keys %a)
>     {
>     if not (/^Fred/){next}
> 
>     code involving $a{$_}  to deal with only elements of the form
> $a{"Fred"}{whatever}
> 
> (also this assumes "Fred" doesn't occur in another index or in longer
> form in the first)
> 
>     }

Hmm .. I am not sure I understand, but is this what you're looking for:

	for my $key (keys %{$a{Fred}}) {
		print $key;
	}

?

--Ala


------------------------------

Date: Mon, 10 Jul 2000 13:04:23 -0400
From: Philip Rennert <phil.rennert@ioip.com>
Subject: Re: multidimensional associative arrays
Message-Id: <396A0217.3DDA5BCA@ioip.com>

Hmm... some constructions here I don't understand.

1) Does %{$a{"Fred"}} refer to a subarray (or sublist) of all elements of the
multidimensional array which have "Fred" as the first index?  If so, how would
you indicate the same thing with "Fred" as the second index?

2) What does "my" mean?

What I want is, given:
$a{"Fred"}{"hello"}=6;
$a{"Fred"}{"goodbye"}=4;
$a{"George"}{"hello"}=3;
$a{"hello"}{"Fred"}=1;
etc.,
sum the values of all elements with "Fred" as the first index, say.

Ala Qumsieh wrote:

> Philip Rennert <phil.rennert@ioip.com> writes:
>
> > When I have a multidimensional array, it's easy to fix one index and
> > iterate on another:
> >
> > for($j=1;$j<=$n;$j++)
> >     {
> >
> >     code involving $a[6][$j]
> >
> >     }
> >
> > but what's a good way to do that with associative arrays, other than the
> > kludgey:
> >
> > foreach( keys %a)
> >     {
> >     if not (/^Fred/){next}
> >
> >     code involving $a{$_}  to deal with only elements of the form
> > $a{"Fred"}{whatever}
> >
> > (also this assumes "Fred" doesn't occur in another index or in longer
> > form in the first)
> >
> >     }
>
> Hmm .. I am not sure I understand, but is this what you're looking for:
>
>         for my $key (keys %{$a{Fred}}) {
>                 print $key;
>         }
>
> ?
>
> --Ala



------------------------------

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 3580
**************************************


home help back first fref pref prev next nref lref last post