in reply to Surprising whitespace behavior
So now that we've determined that "$ x" behaves differently from "@ x", why stop there?
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}".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""
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Surprising whitespace behavior (significant whitespace++)
by tye (Sage) on Sep 23, 2004 at 19:53 UTC |