*{$AUTOLOAD} vs *$AUTOLOAD

J

J Krugman

I frequently see statements like

*{$AUTOLOAD} = \&foobar; # under no strict 'refs'

but I don't understand the need for curly brackets in the LHS
expression. Why not simply

*$AUTOLOAD = \&foobar;

?

TIA!

jill
 
T

Tassilo v. Parseval

Also sprach J Krugman:
I frequently see statements like

*{$AUTOLOAD} = \&foobar; # under no strict 'refs'

but I don't understand the need for curly brackets in the LHS
expression. Why not simply

*$AUTOLOAD = \&foobar;

?

These two statements are equivalent. Note however that the canonical
syntax for a dereference operation is this:

SIGIL := '$' | '%' | '@' | '*'
DEREF := SIGIL '{' EXPRESSION '}'

The curlies can be omitted iff EXPRESSION is a simple scalar which is
the case in your example. If EXPRESSION is a not a scalar variable the
curlies are required.

It's then up to an author's personal preference whether to use the
shortcut or not.

Tassilo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,078
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top