Search code examples
perlfunctionshortcodedefined

Short syntax for call function if defined


is there a shorter syntax or operator for

defined $functionpointer ? $functionpointer->($value) : $value

i would like to have sth like the //-Operator, so that I can shortly write

$functionpointer //->() $value

or anything in that direction

what I don't want to do is write an extra method, overload operators or so


Solution

  • No, there is none. There are discussion, though, about introducing it: What operator should p5p use for safe dereferencing at PerlMonks.