Acme-Glue
view release on metacpan or search on metacpan
# contains the values from the hash sorted by the original hash keys or
# the passed order of columns (hash slicing)
my @ordered = $column_order
? map { [ @$_{ @{ $column_order } } ] } @{ $chaos }
: map { [ @$_{sort keys %$_} ] } @{ $chaos };
## LEEJO (hopscotch.p6)
#!/usr/bin/env perl6
my @court = (
[ 'FIN' ],
[ 9 ,10 ],
[ 8 ],
[ 6 , 7 ],
[ 5 ],
[ 4 ],
[ 2 , 3 ],
[ 1 ],
);
my $skip = @court.[1..*].pick.pick;
my @play;
for @court.reverse -> $hop {
@play.push( $hop.map( *.subst( /^$skip$/,'ð«' ).list ) );
}
say @play.reverse.join( "\n" );
## LEEJO (vec and pack examples from perldoc vec)
#!/usr/bin/env perl -wl
print <<'EOT';
0 1 2 3
unpack("V",$_) 01234567890123456789012345678901
------------------------------------------------------------------
EOT
for $w (0..3) {
$width = 2**$w;
for ($shift=0; $shift < $width; ++$shift) {
for ($off=0; $off < 32/$width; ++$off) {
$str = pack("B*", "0"x32);
$bits = (1<<$shift);
vec($str, $off, $width) = $bits;
$res = unpack("b*",$str);
$val = unpack("V", $str);
write;
}
}
}
format STDOUT =
vec($_,@#,@#) = @<< == @######### @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
$off, $width, $bits, $val, $res
.
__END__
## LEEJO (example from "How Perl Saved the Human Genome Project" complete with syntax error)
use Boulder::Stream;
$stream = new Boulder::Stream;
while ($record=$stream->read_record('NAME','SEQUENCE')) {
$name = $record->get('NAME');
$sequence = $record->get('SEQUENCE');
...continue processing...
$record->add(QUALITY_CHECK=>"OK|);
$stream->write_record($record);
}
## LEEJO (quine - a program that prints itself out)
$_=q(print"\$_=q($_);eval;");eval;
## LEEJO (perl5 LOC count as of 5.38 release)
% git branch
* blead
% find . -name "*.[ch]" | xargs wc -l | sort -nr | head -n5
788279 total
436086 ./charclass_invlists.h
17540 ./sv.c
16254 ./regcomp.c
15712 ./op.c
## LEEJO (fizz\_buzz.pl generated from an "AI"; it's wrong in so many ways, it doesn't even compile)
# Define a function that takes two arguments (starting number and ending number)
sub fizz_buzz {
# Initialize variables for counting and ending values
my $count = 0;
my @results = ();
# Loop through numbers between starting and ending values
for my $i ( $starting .. $ending ) {
# Check if current number is divisible by any of these factors: 15, 3 or itself
foreach my $factor ( @factors ) {
next unless $_ * $i == $i;
push( @{ $results[$factor] },"$i" );
}
else {
push( @{ $results[0] },"$i" );
}
$count++;
}
return \@results;
}
# Define arrays containing factors to check for each result type
my %fizz = ( 15 );
my %buzz = ( 3 );
my %self = ( 0 );
( run in 0.742 second using v1.01-cache-2.11-cpan-5a3173703d6 )