Skip to content

Instantly share code, notes, and snippets.

@mostlyfine
Created December 20, 2011 04:09
Show Gist options
  • Select an option

  • Save mostlyfine/1500212 to your computer and use it in GitHub Desktop.

Select an option

Save mostlyfine/1500212 to your computer and use it in GitHub Desktop.
perl function references
sub test1 {
# reference
return [0, "error"];
}
sub test2 {
# array
return (0, "success");
}
sub test3 {
# hash
return { 1, "aaaa" };
}
my ($result, $error) = @{&test1};
print $result . "\n";
print $error . "\n";
($result, $error) = &test2;
print $result . "\n";
print $error . "\n";
($result, $error) = %{&test3};
print $result . "\n";
print $error . "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment