[Israel.pm] how do I handle unknown number of captures ?

David Baird david.baird at homemail.com
Wed Jan 28 05:00:43 PST 2004

>   > For example, I just typed into bash:
>   >    perl -we '@res="abac--ad"=~/(a.)/g; print "@res\n"'
>   > and received the answer:
>   >    ab ac ad
> Where did the separating space (in the printed result ) come from ?

A quoted string, or the operator qq{}, will take a list like @res, and
return each part of the list with a delimeter. If one were to print @res
without placing it in a quoted string operator ("" is an operator in
Perl), then no spaces would be inserted. The qq{}, qr{}, qx{}, m{}, and
s{}{} operators will interpolate lists (@arr) as (join $", @arr), so you
can also control the delimeter through the $" variable. See perlop for
more details.


More information about the Perl mailing list