Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Calling a sub without enclosing its argument inside brackets

by ikegami (Patriarch)
on Mar 18, 2024 at 04:53 UTC ( [id://11158328]=note: print w/replies, xml ) Need Help??


in reply to Calling a sub without enclosing its argument inside brackets

Add the following to get the desired behaviour:

no feature qw( indirect );

The following has the same effect:

use v5.36;
use v5.38;

Replies are listed 'Best First'.
Re^2: Calling a sub without enclosing its argument inside brackets
by LanX (Saint) on Mar 18, 2024 at 13:17 UTC
    > Add the following to get the desired behaviour:

    > no feature qw( indirect );

    For completeness, he still needs to predeclare the sub palt .

    Either by putting sub palt { ... } earlier or use subs qw(palt); to tell the compiler that it's not a bareword.

    Otherwise he'll get

    Bareword found where operator expected (Do you need to predeclare "palt"?

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery

      For completeness, he still needs to predeclare the sub palt .

      Yeah. That's always the case when calling a sub without parens or &.

      It can also be done using sub palt;.

Re^2: Calling a sub without enclosing its argument inside brackets
by syphilis (Archbishop) on Mar 18, 2024 at 09:14 UTC
    no feature qw( indirect );

    Cool ... thanks ikegami++

    Cheers,
    Rob

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-06-17 22:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.