Re: tricky hash

2005-03-08 Thread Ing. Branislav Gerzo
John W. Krahn [JWK], on Tuesday, March 08, 2005 at 12:58 (-0800) made these points: JWK> my $string = 'something/other/foo/bar'; JWK> my $count; JWK> my $kw = { map { 'cat' . ++$count, $_ } split /\//, $string }; this is really tricky reply I awaited, I like this solution, really nice. Also, in m

Re: tricky hash

2005-03-08 Thread John W. Krahn
Ing. Branislav Gerzo wrote: Hello beginners@perl.org, Hello, 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 "s

Re: tricky hash

2005-03-08 Thread Lawrence Statton
> Hello beginners@perl.org, > > > 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' > Well, fixing the typo where you build the key

Re: tricky hash

2005-03-08 Thread Ankur Gupta
Ing. Branislav Gerzo wrote: 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 } Change this line to for my $cat (split(/\//, 'something/oth

Re: tricky hash

2005-03-08 Thread Wiggins d'Anconia
Ing. Branislav Gerzo wrote: 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 } You don't have to accept the rope Perl will give you to hang y

RE: tricky hash

2005-03-08 Thread Manav Mathur
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->{c

tricky hash

2005-03-08 Thread Ing. Branislav Gerzo
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 i