elbie has asked for the wisdom of the Perl Monks concerning the following question:
Hi all. I have a long list of values which I want to put
into an array, but some of those values have spaces in them.
It would be easiest, I feel, if I could just use qw//, but I can't figure out how to get around the splitting on whitespace.
Right now, my best solution that I can think of would be to use something in place of whitespace, and do a regex on the array later:
my @array = ( qw/one two three four_and_a_half/ ); s/_/ /g for( @array );
But this could get rather cumbersome for large arrays, and at some point in the future, I might need to use whatever character I pick within an element of the array. (Well, okay, I can pick something weird like \007, but ya never know.)
Is there another way to do this?
elbieelbieelbie
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Escaping white space with qw//
by dga (Hermit) on Aug 10, 2001 at 22:02 UTC | |
by John M. Dlugosz (Monsignor) on Aug 10, 2001 at 23:08 UTC | |
by frag (Hermit) on Aug 11, 2001 at 00:52 UTC | |
by John M. Dlugosz (Monsignor) on Aug 11, 2001 at 01:04 UTC | |
Re: Escaping white space with qw//
by thatguy (Parson) on Aug 10, 2001 at 22:06 UTC | |
by dga (Hermit) on Aug 10, 2001 at 22:11 UTC | |
Re: Escaping white space with qw//
by scain (Curate) on Aug 10, 2001 at 22:13 UTC |
Back to
Seekers of Perl Wisdom