12 days of Perl?
4 direct replies — Read more / Contribute
|
by johnaj
on Apr 29, 2021 at 22:03
|
|
I've been working on an exercise to generate the English "Twelve
days of Christmas song". So far, I've come up with the following:
for(<DATA>){s/%/ing/;$_=($i++?$i-1+print"
":a)." $_";print"On the $i",(st,nd,rd)[$i-1]||th," day of Christmas,
my true love gave to me:
",$t=$_.$t}__DATA__
partridge in a pear tree.
turtle doves and
French hens,
call% birds,
golden rings,
geese a-lay%,
swans a-swimm%,
maids a-milk%,
ladies danc%,
lords a-leap%,
pipers pip%,
drummers drumm%,
That generates the following text:
My script is 343 bytes, which is better than zip and tar+gzip but worse than gzip:
-rw-r--r-- 1 john john 294 May 1 13:29 12days.gz
-rw-r--r-- 1 john john 343 Apr 30 04:00 12days.pl
-rw-r--r-- 1 john john 370 May 1 13:30 12days.tar.gz
-rw-r--r-- 1 john john 2169 May 1 13:29 12days.txt
-rw-r--r-- 1 john john 439 May 1 13:30 12days.zip
Does anybody have a shorter solution? For simplicity's sake, I've limited the challenge to digits rather
than written numbers.
|
Binary Comedy -- 01 - 000001
No replies — Read more | Post response
|
by Discipulus
on Apr 07, 2021 at 12:32
|
|
to my father, sure of his pardon :)
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
|
@ISA happy memory
1 direct reply — Read more / Contribute
|
by silent11
on Feb 10, 2021 at 19:18
|
|
I don't post logged in,
socials link to my handle.
I return every few years,
get filled with nostalgia.
Now back to work,
to do whatever.
But not with my Perl,
not today, and likely not ever.
|
Perl Saroyan
1 direct reply — Read more / Contribute
|
by Anonymous Monk
on Sep 11, 2020 at 20:56
|
|
perl -e 'use Time::HiRes qw(usleep); foreach $i (1..145) { print join("", (" " x 72)) . "crickets\n"; usleep 550000 }'
|
the road ahead
1 direct reply — Read more / Contribute
|
by Anonymous Monk
on Oct 14, 2019 at 04:25
|
|
perl -le'$_=`perldoc -T perlfaq4`,s/^.*N;(.*?)E.*$/$1/s,print'
|
obfupoetry II
1 direct reply — Read more / Contribute
|
by Discipulus
on Mar 21, 2019 at 04:46
|
|
In occasion of first day of Spring* i give you the second issue of perl obfupoetry:
How:to:forget:when:I:was:young:
join ' had ', (glob'spr{a,e,i,o,u}ng')[2,4];
Now:I:get:in:the:middle:of:
join ' and ', (glob'Y{i,a}n{,g}')[0,-1];
and:I:remember:it:was:a:bang:
seek DATA,0,0;while(<DATA>){last if/DATA/;
chomp&&print/:/?(join$",split':',$_):eval,$/}
__DATA__
L*
(*)please do not reply with positivist comments about the exact first day of Spring: seasons always start in day 21: the notion is in my mind since..
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
|
The wise coder
2 direct replies — Read more / Contribute
|
by hippo
on Jan 22, 2019 at 14:14
|
|
The wise coder will never pipe grep into awk
For unneeded processes cause neighbours to talk.
The wise coder will never type cat file | foo
Unless they want a UUoCA too.
The wise coder will never discard output from backticks
As that displays ignorance of better tactics.
The wise coder won't shell out to grep, awk or sed
Since no JAPH would be seen doing that, dead.
|
Perl is Magic
No replies — Read more | Post response
|
by usemodperl
on Jun 29, 2018 at 20:27
|
|
Looking for ways to get perl to make Magic?
Any odd way to print that word: like a JAPH!
This shell one liner runs 3 perl one liners that run
perl 4 times to make Magic:
perl -e'$_="Larry";while(++$_){print"\rPerl is $_";goto(MAGIC)if/Magic
+/}MAGIC:print"\n"';perl -v|perl -pe's\Perl\Magic\magic';perl -e'print
+"[Perl$^V] ";<STDIN>'
STOP REINVENTING WHEELS, START BUILDING SPACE ROCKETS!—CPAN 🐪
|
Sex !
1 direct reply — Read more / Contribute
|
by usemodperl
on Jun 21, 2018 at 13:06
|
|
perl -v|perl -pe's\(?<=r)[l]\x\g;s\(?<=pe)r\\gi;s\p(e)\S$1\gi'
perl -MO=Deparse -e 'E S I X G S O O D'
|
a prime bug
1 direct reply — Read more / Contribute
|
by ownlifeful
on Jun 10, 2017 at 21:24
|
|
chomp and print join ',', grep $_, (map length, split /[a,]/), "\n"
while <DATA>;
__END__
a bug trapped inside
a paper lantern, arid
aflutter, ablaze
|