It's ensuring that shift is being evaluated as a function call and not as a literal string.But the only case where that can occur is when the function name might be subject to autoquoting. For instance, on the left hand side of a fat arrow. But all we have here is a thin arrow.
You don't want 'shift' to be seen as a class name, you want it to be evaluated as a function call, and its return value to be used as the class name or object reference.Look again at the original code. The return value of the shift is not treated as a class or an object. Look what's following the arrow: not a method name! The return value of the shift is considered to be a subroutine reference (could be a closure).
Examples:Examples that have nothing to do with the original code. And the + doesn't do what you imply either. Classname->new() is only going to do a call to Classname::new() if there isn't a Classname() subroutine in the currect package. And a + isn't going to change that:
#!/usr/bin/perl use strict; use warnings; package Class; sub foo {"Hello, world"} package Evil; sub foo {"All your base are belong to us"} package main; sub Class {"Evil"} sub bar1 {Class->foo} sub bar2 {+Class->foo} sub bar3 {"Class"->foo} print bar1, "\n"; print bar2, "\n"; print bar3, "\n"; __END__ All your base are belong to us All your base are belong to us Hello, world
In reply to Re^2: What is the + in +shift doing here?
by Anonymous Monk
in thread What is the + in +shift doing here?
by tphyahoo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |