[sf-perl] Windows Perl question
Steve Fink
sphink at gmail.com
Mon Jan 22 13:53:43 PST 2007
On 1/22/07, nheller at silcon.com <nheller at silcon.com> wrote:
>
> It works well.
> One question though: am I correct in assumming "q" is scalar and "qw" is
> array?
I hesitate to say yes, since the terms "scalar" and "array" are usually used
to denote the context of an expression, and that is something being imposed
from outside of the expression itself.
Or, said another way, you could use either one in either context, although
"qw" is pretty useless in scalar context. "q" is the same as a single
quotation mark, just using a (probably) different character to delimit the
string, so it can be used in either context. But it will always produce just
a single (scalar) value.
But if you don't want to dive into it that far, then the answer is yes. "q"
produces a scalar; "qw" produces a list.
q/a b c/ is the same as q[a b c] is the same as 'a b c'
qq/a b c/ is the same as qq[a b c] is the same as "a b c"
qw/a b c/ is the same as ('a', 'b', 'c') is the same as split(/\s+/, "a b
c")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/sanfrancisco-pm/attachments/20070122/5fa6ff90/attachment.html
More information about the SanFrancisco-pm
mailing list