in reply to question related to hash
You could initialise your key/value pairs as an array before transforming into a hash using splice and concatenation in a while loop.
knoppix@Microknoppix:~$ perl -Mstrict -MData::Dumper -e ' > use warnings; > > my @keysAndValues = qw{ > rat acggghhh > mat dhhdhdhdh > rat fhhfjfjj > rat dggdgdgdg > }; > my %hash; > while ( my( $key, $value ) = splice @keysAndValues, 0, 2 ) > { > $hash{ $key } .= $value; > } > print Data::Dumper->Dumpxs( [ \ %hash ], [ qw{ *hash } ] );' %hash = ( 'rat' => 'acggghhhfhhfjfjjdggdgdgdg', 'mat' => 'dhhdhdhdh' ); knoppix@Microknoppix:~$
I hope this is helpful.
Cheers,
JohnGG
|
|---|