Acme-BottomsUp
view release on metacpan or search on metacpan
Acme-BottomsUp
Write individual statements backwards
use Acme::BottomsUp;
@arr # first, start w/ numbers
grep { $_ % 2 } # then get the odd ones
map { $_**3 } # then cube each one
join ":", # and glue together
print # lastly, display result
;
print "ok";
no Acme::BottomsUp;
INSTALLATION
lib/Acme/BottomsUp.pm view on Meta::CPAN
=head1 VERSION
Version 0.02
=head1 SYNOPSIS
my @arr = (1..10);
use Acme::BottomsUp;
@arr # first, start w/ numbers
grep { $_ % 2 } # then get the odd ones
map { $_**3 } # then cube each one
join ":", # and glue together
print # lastly, display result
;
print "ok";
no Acme::BottomsUp;
=head1 DESCRIPTION
This module allows you to write multi-line perl statements in reverse order so that it "reads better". For example, normally one would write the code from the SYNOPSIS as:
my @arr = (1..10);
print # lastly, display result
join ":", # and glue together
map { $_**3 } # then cube each one
grep { $_ % 2 } # then get the odd ones
@arr # first, start with numbers
;
=head1 PREREQUISITES
=over 4
=item *
L<Filter::Simple>
t/odd_cubes.t view on Meta::CPAN
#!/usr/bin/perl -T
use strict;
use warnings;
use Test::More tests=> 2;
my @arr = (1..10);
my $answer = '1:27:125:343:729';
my $x;
use Acme::BottomsUp;
@arr # start w/ numbers
grep { $_ % 2 } # get the odd ones
map { $_**3 } # cube each one
join ":", # glue together
$x = # store result
;
is($x, $answer);
no Acme::BottomsUp;
$x = join ":",
map { $_**3 }
( run in 0.241 second using v1.01-cache-2.11-cpan-0d8aa00de5b )