use warnings ; use strict ; my %h = ( 'a' => 1, 'b' => 1, 'c' => 1 ) ; my $str ; foreach ( keys %h ) { $str .= "$_ " } xyz( $str ) ; sub xyz { print shift ; } #### use warnings ; use strict ; my %h = ( 'a' => 1, 'b' => 1, 'c' => 1 ) ; xyz( "keys(%h)" ) ; sub xyz { print shift ; }