in reply to how to use join my array ?
It is not clear exactly what you are trying to achieve. It looks like you want to create an array @ab that contains just the keys from the hash %abc, each with a hypen prepended.
use strict; use warnings; my %abc = ( to => 'def', from => 'ghi', ); my @ab; for ( keys %abc ) { push @ab, "-$_"; } print "$_\n" for @ab; #Output -to -from
Will do that, or you can use map to do the same thing.
use strict; use warnings; my %abc = ( to => 'def', from => 'ghi', ); my @ab = map { "-$_" } keys %abc; print "$_\n" for @ab;
As doing this disconnects the modified keys from their previously associated values, I guess this is not really what you want. I think it is more likely that you want to just modify the keys in the hash, or more simply create a new hash with the modified keys.
my %ab = map { '-' .$_ => $abc{$_} } keys %abc;
|
---|
In Section
Seekers of Perl Wisdom