my $input = 'hello'; my $temp = 'world'; my @temp = split('', $input); push @temp, ' '; push @temp, $_ for split('', $temp); $input = join('',@temp);