blib/lib/Acme/Glue.pm untested

filter: Statementstmt 0.0% 0 / 10 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod n/a totaltotal 0.0% 0 / 13 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Acme::Glue;
2  
3 use utf8;
4 use strict;
5 use warnings;
6  
7 $Acme::Glue::VERSION = "2023.10";
8  
9 =encoding utf8
10  
11 =head1 NAME
12  
13 Acme::Glue - A placeholder module for code accompanying a Perl photo project
14  
15 =head1 VERSION
16  
17 2023.10
18  
19 =head1 DESCRIPTION
20  
21 Acme::Glue is the companion Perl module for a Perl photo project, the idea
22 for the photo project is to have each photo include a small snippet of code.
23 The code does not have to be Perl, it just has to be something you're quite
24 fond of for whatever reason.
25  
26 "Glue" is a series of photos shot at Perl conferences and workshops in Europe
27 and America. Perl was one of the programming languages that bootstrapped a
28 lot of internet based companies in the mid/late 1990s and early 2000s. Perl
29 was considered a “glue” language by some, but has fallen out of favour as
30 newer languages have taken its place. The title is a metaphor not just for
31 the language but also for shrinking of the community at the events the photos
32 are shot at.
33  
34 =head1 SNIPPETS
35  
36 Here are the snippets that may accompany the photo project
37  
38 =head2 LEEJO (transform.pl)
39  
40 #!/usr/bin/env perl
41 #
42 # transform an array of hashes into an array of arrays where each array
43 # contains the values from the hash sorted by the original hash keys or
44 # the passed order of columns (hash slicing)
45 my @ordered = $column_order
46 ? map { [ @$_{ @{ $column_order } } ] } @{ $chaos }
47 : map { [ @$_{sort keys %$_} ] } @{ $chaos };
48  
49 =head2 LEEJO (hopscotch.p6)
50  
51 #!/usr/bin/env perl6
52  
53 my @court = (
54 [ 'FIN' ],
55 [ 9 ,10 ],
56 [ 8 ],
57 [ 6 , 7 ],
58 [ 5 ],
59 [ 4 ],
60 [ 2 , 3 ],
61 [ 1 ],
62 );
63  
64 my $skip = @court.[1..*].pick.pick;
65 my @play;
66  
67 for @court.reverse -> $hop {
68 @play.push( $hop.map( *.subst( /^$skip$/,'🚫' ).list ) );
69 }
70  
71 say @play.reverse.join( "\n" );
72  
73 =head2 LEEJO (vec and pack examples from perldoc vec)
74  
75 #!/usr/bin/env perl -wl
76  
77 print <<'EOT';
78 0 1 2 3
79 unpack("V",$_) 01234567890123456789012345678901
80 ------------------------------------------------------------------
81 EOT
82  
83 for $w (0..3) {
84 $width = 2**$w;
85 for ($shift=0; $shift < $width; ++$shift) {
86 for ($off=0; $off < 32/$width; ++$off) {
87 $str = pack("B*", "0"x32);
88 $bits = (1<<$shift);
89 vec($str, $off, $width) = $bits;
90 $res = unpack("b*",$str);
91 $val = unpack("V", $str);
92 write;
93 }
94 }
95 }
96  
97 format STDOUT =
98 vec($_,@#,@#) = @<< == @######### @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
99 $off, $width, $bits, $val, $res
100 .
101 __END__
102  
103 =head2 LEEJO (example from "How Perl Saved the Human Genome Project" complete with syntax error)
104  
105 use Boulder::Stream;
106 $stream = new Boulder::Stream;
107 while ($record=$stream->read_record('NAME','SEQUENCE')) {
108 $name = $record->get('NAME');
109 $sequence = $record->get('SEQUENCE');
110  
111 ...continue processing...
112  
113 $record->add(QUALITY_CHECK=>"OK|);
114 $stream->write_record($record);
115 }
116  
117 =head2 LEEJO (quine - a program that prints itself out)
118  
119 $_=q(print"\$_=q($_);eval;");eval;
120  
121 =head2 LEEJO (perl5 LOC count as of 5.38 release)
122  
123 % git branch
124 * blead
125 % find . -name "*.[ch]" | xargs wc -l | sort -nr | head -n5
126 788279 total
127 436086 ./charclass_invlists.h
128 17540 ./sv.c
129 16254 ./regcomp.c
130 15712 ./op.c
131  
132 =head2 MIKESTOK (soundex "joke")
133  
134 sub Soundex
135 {
136 local ($_, $f) = shift;
137  
138 y;a-z;A-Z;;y;A-Z;;cd;$_ ne q???do{($f)=m;^(.);;s;$f+;;;
139 y;AEHIOUWYBFPVCGJKQSXZDTLMNR;00000000111122222222334556;;
140 y;;;cs;y;0;;d;s;^;$f;;s;$;0000;;m;(^.{4});;$1;}:q;;;
141 }
142  
143 =head2 NERDVANA (delorean_ options.pl)
144  
145 GetOptions(
146 'help|h|?' => sub { pod2usage(1) },
147 'serial-dev|d=s' => \my $opt_serial_dev= '/dev/delorean',
148 'socket|S=s' => \my $opt_socket= '/run/uctl-daemon.sock',
149 ) or pod2usage(2);
150  
151 =head2 SLU (MAZE.BAS)
152  
153 10 PRINT CHR$(205.5+RND(1));:GOTO 10
154  
155 =head2 SLU (schwartzian_transform.pl)
156  
157  
158 #!/usr/bin/env perl
159 # https://en.wikipedia.org/wiki/Schwartzian_transform
160 # Sort list of words according to word length
161  
162 print "$_\n" foreach
163 map { $_->[0] }
164 sort { $a->[1] <=> $b->[1] or $a->[0] cmp $b->[0] }
165 map { [$_, length($_)] }
166 qw(demo of schwartzian transform);
167  
168 =head1 THANKS
169  
170 Thanks to all who contributed a snippet
171  
172 =head1 SEE ALSO
173  
174 L<https://www.formulanon.com/glue>
175  
176 L<https://www.youtube.com/watch?v=ir6f2SvsXPA&feature=youtu.be&list=PLOOlhkMvt_o4y627mpaCGrO4ughSEeUgb&t=1046>
177  
178 L<https://leejo.github.io/acme-glue-talk/presentation.html#1>
179  
180 =head1 AUTHOR
181  
182 Lee Johnson - C<leejo@cpan.org>
183  
184 =head1 LICENCE
185  
186 This library is free software; you can redistribute it and/or modify it under
187 the same terms as Perl itself. If you would like to contribute documentation,
188 features, bug fixes, or anything else then please raise an issue / pull request:
189  
190 https://github.com/leejo/acme-glue
191  
192 All photos © Lee Johnson
193  
194 =cut
195  
196 1;