> 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 for the last assignment
would help with your immediate problem.  *HOWEVER*  You're still
solving the problem in a wrong-way.

*EVERY TIME* you see a list of variable names (or hash keys) of the
form foo1 foo2 foo3 foo4 that should be a GIANT WAVING RED FLAG that
your data model is lacking.

Lacking is not strong enough a word.

How about "is pessimally awful."

"...deserves never to see the light of day."

Perl has a built in data type highly suited for a series of data
indexed by a monotonically increasing integer.  The List.

my @keyword = split ( /\//, 'something/wicked/this/way/comes' ) ;

If you like the refence version of it

my $keywords = [ split (/\//, 'something/wicked/this/way/comes') ] ;

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
        Lawrence Statton - [EMAIL PROTECTED] s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
sort them into the correct order.








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