DEVFYI - Developer Resource - FYI

What does `new $cur->{LINK}' do? (Assume the current package has no new() function of its own.)

Perl Questions and Answers


(Continued from previous question...)

What does `new $cur->{LINK}' do? (Assume the current package has no new() function of its own.)

$cur->new()->{LINK}
The indirect object syntax only has a single token lookahead. That means if new() is a method, it only grabs the very next token, not the entire following expression.
This is why `new $obj[23] arg' does't work, as well as why `print $fh[23] "stuff\n"' does't work. Mixing notations between the OO and IO notations is perilous. If you always use arrow syntax for method calls, and nothing else, you'll not be surprised.

(Continued on next question...)

Other Interview Questions