in reply to loop through values in a string and print " " around each value.

First of all, your best off using one of the CSV / xSV modules.

Secondly, what if the string contains "? I'll use Perl-like backslash escaping.

sub quote { # Use $_ if no arguments are provided. my $s = @_ ? $_[0] : $_; $s =~ s/([\\"])/\\$1/g; return qq{"$s"}; } # Procedural style print quote foreach @zip; print "\n"; # Functional style print map quote, @zips; print "\n";

Replies are listed 'Best First'.
Re^2: loop through values in a string and print " " around each value.
by kevyt (Scribe) on Jan 12, 2007 at 02:17 UTC
    Nice. I might be able to use this later in the code. Thanks