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


In reply to Re: Surprising whitespace behavior by QM
in thread Surprising whitespace behavior by steves

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.