On Sun, Jun 22, 2003 at 12:08:53AM -0400, Mike Simons wrote:
> On Sat, Jun 21, 2003 at 05:22:17PM -0700, Peter Jay Salzman wrote:
> > when using a quoting operator like qw and friends, how does one one
> > quote a string with spaces?
> 
> You don't.
> 
> >   foreach my $county (qw/Amador Calaveras 'El Dorado' Humboldt Lake Tehama 
> > Trinity/)
> 
> You could do something similar to this:
> ===
> foreach (split ",", 
>                'Amador,Calaveras,El Dorado,Humboldt,Lake Tehama,Trinity') {
>   print "$_\n";
> }

Also possible:

        foreach my $county ('Amador', 'Calaveras', 'El Dorado', ...) {
                <perform actions>
        }

but that does not avoid quotes and commas, the point of the qw// operator.
Escaping the pace using \ does not work, either :-(.

At the risk of being annoying, I will mention that the analogous operator in
Ruby does support just that.

        #!/usr/bin/ruby
        %w[Amador Calaveras El\ Dorado].each do |i|
                puts i
        end

iterates over three array elements as expected, not four.

-- 
Henry House
The unintelligible text that may follow is a digital signature. 
See <http://hajhouse.org/pgp> for information.  My OpenPGP key:
<http://hajhouse.org/hajhouse.asc>.

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to