Here is a mini-cgi to show how to install it into the Template list operations.
use strict;
use CGI qw( header start_html );
use Template;
use List::Util;
$Template::Stash::LIST_OPS->{shuffle} =
sub {
List::Util::shuffle @{ +shift || [] };
};
my $tt2 = Template->new();
print
header(),
start_html(-title => "Template::Toolkit Shuffle");
my @cards = ( 2 .. 10, qw( A K Q J ) );
my @deck;
for my $suit ( qw( S H C D ) ) {
push @deck, map { "$_$suit" } @cards;
}
$tt2->process(\*DATA, { deck => \@deck })
or warn $Template::ERROR;
__DATA__
<h1>Template::Toolkit Shuffle</h1>
[% FOR i IN deck.shuffle %]
[% i %]
[% '<br />' UNLESS loop.count % 5 %]
[% END %]
It means, “call the cops,” mom. But I’ve asked you more than once to just ask and quit searching my websites for popular culture references you overhear when you’re dropping me off at the methadone clinic.
[close]
Permanent link · http://querylog.com/q/%22dropping+the+dime%22+definition