in reply to Re: why avoid & on function call
in thread why avoid & on function call
The placement of a sub is important onlymainly when you call it without parentheses, i.e. as a bareword. When such a call is being parsed, the subs already parsed are recognised and the bareword is parsed as their call, otherwise without strict, the bareword is stringified, and with strict, you get an error.
Uncommenting the last last print line would make the source unparsable with#!/usr/bin/perl use warnings; print "", frob(); # 12 print "", frob; # frob use strict; print "", frob(); # 12 # print "", frob; sub frob { 12 }
Bareword "frob" not allwoed while "strict subs" in use
Updated: as shown in the text, thanks kcott.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: why avoid & on function call
by kcott (Archbishop) on Dec 27, 2020 at 19:14 UTC | |
Re^3: why avoid & on function call
by LanX (Saint) on Dec 27, 2020 at 17:59 UTC |
In Section
Seekers of Perl Wisdom