Skip to content

Instantly share code, notes, and snippets.

@MidLifeXis
Last active May 6, 2019 15:48
Show Gist options
  • Select an option

  • Save MidLifeXis/7948590 to your computer and use it in GitHub Desktop.

Select an option

Save MidLifeXis/7948590 to your computer and use it in GitHub Desktop.
Perl toolbox
#!/usr/bin/perl
# Not certain if this will ever be useful, but thanks to choroba@perlmonks.
use warnings;
use strict;
my $join = sub {join pop, @{shift()} };
my $grep = sub { my $f = pop; [ grep {$f->($_)} @{shift()} ]};
my $say = sub { print( @_, "\n" ) };
[1 .. 200]->$grep(sub { /0/ } )
->$grep(sub { /1/ } )
->$join("\n")
->$say("\nIt works!");
# Perhaps even something like:
reduce { $a->$b } \@data, @subs;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment