Gufranul Haque wrote:
> Hello all,
>
> I need to process a record
>
> Key1 3.00 4.00 5.00
>
> I need to trap spaces between nonwhitespace characters as array
> elements i.e for the above record
> the resulting array should be
> (' ',' ',' ')
>
> The staement that I am using
>
> my @spaces = map /(\s+)/, $_;
>
> is able to trap only the 3 whitespaces between Key1 and 3.00 (' ')
You're using 'map' to map a single element list ($_), so
your statement is the same as:
my @spaces = $_ =~/(\s+)/;
or just
my @spaces = /\s+/;
You can make this statement return _all_ of the space sequences
by using the /g modifier.
my @spaces = /\s+/g;
but I suspect that you may want all of the non-space data as well.
my @everything = split /(\s+)/;
will return all the data and all of the spaces:
print join ", ", map "'$_'", @everything;
output
'Key1', ' ', '3.00', ' ', '4.00', ' ', '5.00'
HTH,
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]