use strict; use warnings; my %abc = ( to => 'def', from => 'ghi', ); my @ab; for ( keys %abc ) { push @ab, "-$_"; } print "$_\n" for @ab; #Output -to -from