Ah. Sorry, kind of glossed over the "slice" aspect there. All right, try this then.
use Data::Dumper;
sub mydump($) {
print Data::Dumper->Dump( [ $_[0] ], ['*hash'] );
}
sub myjoin {
my ($sep, $href, @keys) = @_;
my @exists = grep { exists($href->{$_}) } @keys;
return join $sep, @exists;
}
my %hash = (key1 => 'a');
my $s1 = join( ':', @hash{qw(key)} );
mydump( \%hash );
my $s2 = myjoin( ':', \%hash, qw/key1 key2 key3/ );
mydump( \%hash );
|