in reply to What for sigils were allowed to be separated from identifiers?

perl parser is not interested in spaces until the code it's clear, at least from perl point of view.

This is a good thing for you, infact you can print a boublequoted string as multiline expression.

If you by other hand insert (even if allowed) white spaces between sigils and identifiers, you are somehow shooting on your own feet.

Anyway perlintro states:

> Whitespace is irrelevant:

print "Hello, world" ;

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
  • Comment on Re: What for sigils were allowed to be separated from identifiers?
  • Download Code

Replies are listed 'Best First'.
Re^2: What for sigils were allowed to be separated from identifiers?
by Eily (Monsignor) on Nov 29, 2017 at 17:21 UTC

    Whitespace is irrelevant
    p r i n t "Hello, world"; doesn't print "Hello, world" though, so you can't just put whitespace anywhere.
    Also $x = "Hello"; print "$ x" will print "Hello" but @x = "Hello"; print "@ x" will print "@ x", and @$ x, $# x and $ #x are all syntax errors unless you remove the spaces.
    #Edited: added those examples use feature 'say'; our $x = "Hello"; our @y = "Hi"; our $z = ["Bonjour"]; while (<DATA>) { chomp; print "$_ \t"; no warnings; eval "$_; 1" or say $@ =~ tr/\n/ /r; } __DATA__ say "$x"; say "$ x"; say "@y"; say "@ y"; say @ y; say $#y; say $# y; say $ #y; say @ $z; say @$ z;
    say "$x"; Hello say "$ x"; Hello say "@y"; Hi say "@ y"; @ y say @ y; Hi say $#y; 0 say $# y; syntax error at (eval 6) line 2, at EOF (Might be a +runaway multi-line ;; string starting on line 1) say $ #y; syntax error at (eval 7) line 1, at EOF say @ $z; Bonjour say @$ z; syntax error at (eval 9) line 1, near "@$ z"

    If you [...] insert [...] white spaces between sigils and identifiers, you are somehow shooting on your own feet.
    If you do it on purpose yes, but it's pretty easy to do it by mistake, either because of a typo, or because you expected spaces to be relevant inside a string, or even in some cases without noticing what's wrong, and perl may not warn you:
    use v5.14; use strict; use warnings; use constant MASK => 0xF0; use constant VAL => 0x0F; sub get_val1 { VAL } sub get_val2() { VAL } sub get_mask { MASK } # Is & a function sigil or the bitwise and? say VAL & get_mask; say get_val1 & get_mask; say get_val1 & MASK; say get_val2 & MASK; say get_val1() & MASK;
    0 15 15 0 0

Re^2: What for sigils were allowed to be separated from identifiers?
by vr (Curate) on Nov 29, 2017 at 17:00 UTC

    > Whitespace is irrelevant

    Yes indeed, and don't I over-abuse this fact with non-standard indentation, building geometric figures from my source, to help me better read and remember what it was, in 1-2 years. But I never saw sigils standing separate, even in code meant for puzzling and obfuscation, e.g. this, have you?