Not knowing which post to reply to...
So now that we've determined that "$ x" behaves differently from "@ x", why stop there?
DB<1> $x = 'DollarX'
DB<2> @x = 'a'..'g'
DB<3> %x = qw(1 a 2 b 3 c)
DB<4> sub x { print "This is Sub x\n" }
DB<5> p "<$x> <@x> <%x> <&x>"
<DollarX> <a b c d e f g> <%x> <&x>
DB<6> p "<$ x> <@ x> <% x> <& x>"
<DollarX> <@ x> <% x> <& x>
DB<7> p "$ #x"
Final $ should be \$ or $name at (eval 12)[C:/Perl/lib/perl5db.pl:17]
+line 2, within string
syntax error at (eval 12)[C:/Perl/lib/perl5db.pl:17] line 2, near "}
+"$ #x""
So
"$ x" is the only one this works for, and it breaks for
"$ #x", even though that looks like a scalar (and it probably shouldn't break!). But
"$ x[0]" produces
"a", and so does
"$ x{1}".
I'm sure there's some Good Reason Why This Is So...Perhaps it's easy to figure out what to do with "$x", but there are more options with "@x". The string interpolation aspect of ignoring whitespace was probably not updated when "@x" interpolation was added. [I secretly hoped Merlyn would have the skinny on that -- but I'm sure he would have said so.]
-QM
--
Quantum Mechanics: The dreams stuff is made of