How to run an anonymous function in Perl?

(sub { ... }) will give you the pointer to the function so you must call by reference.

(sub { print "Hello world\n" })->();

The other easy method, as pointed out by Blagovest Buyukliev would be to dereference the function pointer and call that using the { } operators

&{ sub { print "Hello World" }}();

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)