use strict;
use warnings;
use Data::Dumper ;
my %kw = ();
my $kw = \%kw;
my $i = 1;
for my $cat (split(/\//, 'something/other/foo/bar'))
{
$kw->{"cat".eval{$i++}} = $cat
}
print Dumper \%kw ;

-----Original Message-----
From: Ing. Branislav Gerzo [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 08, 2005 10:14 PM
To: beginners@perl.org
Subject: tricky hash


Hello beginners@perl.org,

anyone could me help with:

use strict;
use warnings;
my %kw = ();
my $kw = \%kw;
for my $cat (split(/\//, 'something/other/foo/bar')) { $kw->{cnt}++;
$kw->{cat${kw->{cnt}}} = $cat }


I get: Can't use bareword ("kw") as a HASH ref while "strict refs" in
use..
The goal is to get something like:
$kw->{cat1} = 'something',
$kw->{cat2} = 'other',
$kw->{cat3} = 'foo',
$kw->{cat4} = 'bar'

anyone?

--

 --. ,--  ,-     ICQ: 7552083      \|||/    `//EB: www.2ge.us
,--' |  - |--    IRC: [2ge]        (. .)    ,\\SN: 2ge!2ge_us
`====+==+=+===~  ~=============-o00-(_)-00o-================~
When hell freezes over?  I just sold Satan a fur coat the other day...





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



*********************************************************
Disclaimer:

The contents of this E-mail (including the contents of the enclosure(s) or 
attachment(s) if any) are privileged and confidential material of MBT and 
should not be disclosed to, used by or copied in any manner by anyone other 
than the intended addressee(s).   In case you are not the desired addressee, 
you should delete this message and/or re-direct it to the sender.  The views 
expressed in this E-mail message (including the enclosure(s) or attachment(s) 
if any) are those of the individual sender, except where the sender expressly, 
and with authority, states them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be free of 
any virus.  However, it is the responsibility of the recipient to ensure that 
it is virus free and MBT is not responsible for any loss or damage arising in 
any way from its use

*********************************************************

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to