Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

white spaces between the sigil and the variable ( $ x = )

by Anonymous Monk
on Oct 14, 2008 at 23:19 UTC ( [id://717113]=perlmeditation: print w/replies, xml ) Need Help??

You learn something new every day :)
http://dev.perl.org/perl6/doc/design/syn/S02.html
Unlike in Perl 5, you may no longer put whitespace between a sigil and its following name or construct.
perl -wle" my $ x = 6; die $x " 6 at -e line 1.
Haven't noticed this in the perldocs (probably a good thing).

Replies are listed 'Best First'.
Re: white spaces between the sigil and the variable ( $ x = )
by JavaFan (Canon) on Oct 15, 2008 at 00:12 UTC
    Note that you can put a newline after the sigil most of the time as well, except for many of the punctuation variables - the parser accepts spaces after the sigil, but not newlines.

    I've known for this quite some time, and I tried to make a JAPH with no line being more than one character wide 1. I haven't succeeded. A quicky attempt I just made (my original tries have been lost in time), run with 'perl -M5.010':

    $ _ = q q J u s t a n o t h e r P e r l H a c k e r q ; s s s seg&say
    (None of the lines above match /^$/)

    1  To avoid having to write I have this amazing JAPH, but the margin isn't wide enough for it...

Re: white spaces between the sigil and the variable ( $ x = )
by eyepopslikeamosquito (Archbishop) on Oct 15, 2008 at 07:07 UTC

    I stumbled upon this while composing Saturn when, to accurately fit the Saturn shape, I needed to split $I across two lines here:

    $_=_^q-q-),&$I(20,41-!q- ;;; -,$_=F|K),$ I->(15,31,$_=&$R(4-!q- ;;; -)),&$I(13-!"

Re: white spaces between the sigil and the variable ( $ x = )
by blazar (Canon) on Oct 16, 2008 at 05:38 UTC

    I personally believe (but I am not 100% sure) it was Abigail (who is "our" Abigail as well) in clpmisc who originally "told" me about this feature: if not him, then certainly someone else there.

    --
    If you can't understand the incipit, then please check the IPB Campaign.
      (who is "our" Abigail as well)

      Alas, not any more, since some years now. - But it must be him; his main objection to Perl 6 is significant whitespace, and I'm with him on that one. I detest python for it's significant whitespace (or abuse of indentation) - python scripts look like full of dangling code to me - and I love the whitespace liberty of perl 5 which lets me align code vertically, like in

      $foo {three} = $doit -> (1 ); $quux {two} = get_that (25);

      which improves readability, imho.

        In Perl6, you don't have to give your aligning up...
        $foo. <<three>> = $doit. (1); $quux. <<two> = get_that(25);
        ... or something :-)
        []s, HTH, Massa (κς,πμ,πλ)
        $foo{ three } = $doit->( 1 ); $quux{ two } = get_that( 25 );

        There. All better now :) (And (probably?) compatible with Perl 6)

        My justifictions:

        1. $foo  {three} looks like the scalar $foo juxtaposed against a bare-block containing a bareword.

          Conversely, this $foo{ says, hash; and this $foo{ three } is clearly addressing the element keyed with three in the hash named %foo.

        2. Ditto $quux {two}
        3. $doit -> (1 ); looks like the scalar $foo fired an arrow at a big-bottomed girl's left butt-cheek.

          Conversely, this $doit->(   1 ) obviously dereferences the scalar $doit and attempts to call it as a subroutine passing 1 as the parameter.

        4. get_that (25) reads like an extract from a foriegn correspondant's newspaper article: "The bride, get_that (25), was resplendent in her gown of layered white taffeta..."

          Whereas this get_that( 25 ); is obviously calling a subroutine.

          Though if you're using a small enough font, that silly underscore seems to disappear, and suddenly it turns into Patrick McGoohan giving an order to that bit-part cast member you knew was destined to die this episode, because of his identifier.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
        (who is "our" Abigail as well)

        Alas, not any more, since some years now. - But it must be him; his main objection to Perl 6 is significant whitespace, and I'm with him on that one.

        I personally believe that it was clear enough I was using "our" (in quotes, in fact) in the Pooh sense: indeed it used to be him, then he had an idiosyncrasy with the environment here, and voting and the like; he's definitely a clpmisc-kinda-guy. As you can clearly understand, he's rather radical in his choices and judgements - this whitespace thingie included. In fact Perl 6 is admittedly more whitespace sensitive than Perl 5, but... not that much! To even remotely mention Python (which has indentation as part of the syntax!) in these respects sounds mostly like a heresy to me!

        Anyway tastes are tastes and Abigail is to say the least an extremely resourceful and skilled Perl hacker far above the top of my head, but as a general rule he found Perl 6's design to be too clean and neat, while he cherishes the "medieval-castle-like characteristics" of Perl 5. A matter we may discuss for hours without getting anything out of it if we have contrasting opinions...

        --
        If you can't understand the incipit, then please check the IPB Campaign.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://717113]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-26 03:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found