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 yourself,

$kw->{'cat'.$kw->{'cnt'}} = $cat;

The special quoting Perl does on hash keys is really only useful for simple strings.

Perl also ignores whitespace for a reason, consider not writing whole programs on one line, it will help you with debugging.



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?


http://danconia.org

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