Skip to content

Instantly share code, notes, and snippets.

@andrewsolomon
Created May 21, 2017 20:29
Show Gist options
  • Save andrewsolomon/e53137b1c9710c9778e19d7c97387153 to your computer and use it in GitHub Desktop.
Save andrewsolomon/e53137b1c9710c9778e19d7c97387153 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dump 'pp';
use feature 'say';
my $r_foo = sub { return "foo"; };
my $r_bar = sub { return {this => 1, that => 2}; };
sub call_sub {
my $sub = shift;
my $retval = $sub->();
return $retval;
}
say 'r_foo returns '.pp(call_sub($r_foo));
say 'r_bar returns '.pp(call_sub($r_bar));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment