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 my case, the best is:

use strict;
use warnings;
use Data::Dumper ;

my %kw = ();
my $kw = \%kw;
$kw = { map { 'cat' . ++$kw->{cnt}, $_ } split /\//, 'something/other/foo/bar' 
};
print Dumper $kw;

__END__
$VAR1 = {
          'cat2' => 'other',
          'cat3' => 'foo',
          'cat1' => 'something',
          'cat4' => 'bar'
        };

Interesting on this is, $kw->{cnt} doesn't exist :)

Thanks to all who replied!

-- 

 ...m8s, cu l8r, Brano.

[Is a white person from Africa an African-American?]



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