I have a string like this:
a b c d
I process my string like this:
chomp $line;
my @tokens = split /\s+/, $line;
my @new_tokens;
foreach my $token (@tokens) {
push @new_tokens, some_complex_function( $token );
}
my $new_str = join ' ', @tokens;
I'd like to re-join the string with the original whitespace. Is there some way that I can store the whitespace from split and re-use it later? Or is this going to be a huge pain? It's mostly cosmetic, but I'd like to preserve the original spaces from the input string.