Skip to content

Instantly share code, notes, and snippets.

@tyru
Created February 24, 2009 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyru/69344 to your computer and use it in GitHub Desktop.
Save tyru/69344 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
sub my_map (&@) {
my $code = shift;
my @array;
for (@_) {
local $_ = $_;
push @array, $code->();
}
return @array;
}
my @d = my_map { $_ ** 2 } ( 1, 2, 3, 4, 5 );
print "@d", "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment