Skip to content

Instantly share code, notes, and snippets.

@uname-yang
Created August 24, 2017 02:43
Show Gist options
  • Save uname-yang/2a3023ebb14f6dc0c4eddf4a35c6908b to your computer and use it in GitHub Desktop.
Save uname-yang/2a3023ebb14f6dc0c4eddf4a35c6908b to your computer and use it in GitHub Desktop.
reflect [Perl]
#!/usr/bin/perl -w
sub add{
my($a,$b)=@_;
print $a+$b;
return $a+$b;
}
'add'->(1,2);
$addSub='add';
$addSub->(1,2);
@arr=('add','sub','multi');
$arr[0]->(1,2);
%hash=(
'add'=>'add',
'sub'=>sub{ my($a,$b)=@_;
return $a-$b;
}
);
$hash{'add'}->(1,2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment