Whitespace is irrelevantp r i n t "Hello, world"; doesn't print "Hello, world" though, so you can't just put whitespace anywhere.
#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
In reply to Re^2: What for sigils were allowed to be separated from identifiers?
by Eily
in thread What for sigils were allowed to be separated from identifiers?
by vr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |