Anonymous subroutines
#!/usr/bin/perl
use strict;
use warnings;
my $add_ref = sub {
my ($x, $y) = @_;
return $x+$y;
};
print &{ $add_ref }(2, 3), "\n";
print $add_ref->(2, 3), "\n";
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
#!/usr/bin/perl
use strict;
use warnings;
my $add_ref = sub {
my ($x, $y) = @_;
return $x+$y;
};
print &{ $add_ref }(2, 3), "\n";
print $add_ref->(2, 3), "\n";