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 = "2025.11";
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 2025.11
18  
19 =head1 DESCRIPTION
20  
21 =begin HTML
22  
23 <p><img src="https://images.squarespace-cdn.com/content/v1/60f40aa1942bba66cf802d7d/1626967232855-GP54O7LH9BAGBGAXJXUJ/05_yapc_eu_2016_f04.jpg?format=625w"
24 width="650" alt="Acme::Glue Photo" /></p>
25  
26 =end HTML
27  
28 Acme::Glue is the companion Perl module for a Perl photo project, the idea
29 for the photo project is to have each photo include a small snippet of code.
30 The code does not have to be Perl, it just has to be something you're quite
31 fond of for whatever reason.
32  
33 "Glue" is a series of photos shot at Perl conferences and workshops in Europe
34 and America. Perl was one of the programming languages that bootstrapped a
35 lot of internet based companies in the mid/late 1990s and early 2000s. Perl
36 was considered a “glue” language by some, but has fallen out of favour as
37 newer languages have taken its place. The title is a metaphor not just for
38 the language but also for shrinking of the community at the events the photos
39 are shot at.
40  
41 =head1 SNIPPETS
42  
43 Here are the snippets that may accompany the photo project
44  
45 =head2 LEEJO (transform.pl)
46  
47 #!/usr/bin/env perl
48 #
49 # transform an array of hashes into an array of arrays where each array
50 # contains the values from the hash sorted by the original hash keys or
51 # the passed order of columns (hash slicing)
52 my @ordered = $column_order
53 ? map { [ @$_{ @{ $column_order } } ] } @{ $chaos }
54 : map { [ @$_{sort keys %$_} ] } @{ $chaos };
55  
56 =head2 LEEJO (hopscotch.p6)
57  
58 #!/usr/bin/env perl6
59  
60 my @court = (
61 [ 'FIN' ],
62 [ 9 ,10 ],
63 [ 8 ],
64 [ 6 , 7 ],
65 [ 5 ],
66 [ 4 ],
67 [ 2 , 3 ],
68 [ 1 ],
69 );
70  
71 my $skip = @court.[1..*].pick.pick;
72 my @play;
73  
74 for @court.reverse -> $hop {
75 @play.push( $hop.map( *.subst( /^$skip$/,'🚫' ).list ) );
76 }
77  
78 say @play.reverse.join( "\n" );
79  
80 =head2 LEEJO (vec and pack examples from perldoc vec)
81  
82 #!/usr/bin/env perl -wl
83  
84 print <<'EOT';
85 0 1 2 3
86 unpack("V",$_) 01234567890123456789012345678901
87 ------------------------------------------------------------------
88 EOT
89  
90 for $w (0..3) {
91 $width = 2**$w;
92 for ($shift=0; $shift < $width; ++$shift) {
93 for ($off=0; $off < 32/$width; ++$off) {
94 $str = pack("B*", "0"x32);
95 $bits = (1<<$shift);
96 vec($str, $off, $width) = $bits;
97 $res = unpack("b*",$str);
98 $val = unpack("V", $str);
99 write;
100 }
101 }
102 }
103  
104 format STDOUT =
105 vec($_,@#,@#) = @<< == @######### @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
106 $off, $width, $bits, $val, $res
107 .
108 __END__
109  
110 =head2 LEEJO (example from "How Perl Saved the Human Genome Project" complete with syntax error)
111  
112 use Boulder::Stream;
113 $stream = new Boulder::Stream;
114 while ($record=$stream->read_record('NAME','SEQUENCE')) {
115 $name = $record->get('NAME');
116 $sequence = $record->get('SEQUENCE');
117  
118 ...continue processing...
119  
120 $record->add(QUALITY_CHECK=>"OK|);
121 $stream->write_record($record);
122 }
123  
124 =head2 LEEJO (quine - a program that prints itself out)
125  
126 $_=q(print"\$_=q($_);eval;");eval;
127  
128 =head2 LEEJO (perl5 LOC count as of 5.38 release)
129  
130 % git branch
131 * blead
132 % find . -name "*.[ch]" | xargs wc -l | sort -nr | head -n5
133 788279 total
134 436086 ./charclass_invlists.h
135 17540 ./sv.c
136 16254 ./regcomp.c
137 15712 ./op.c
138  
139 =head2 LEEJO (fizz_buzz.pl generated from an "AI"; it's wrong in so many ways, it doesn't even compile)
140  
141 # Define a function that takes two arguments (starting number and ending number)
142 sub fizz_buzz {
143  
144 # Initialize variables for counting and ending values
145 my $count = 0;
146 my @results = ();
147  
148 # Loop through numbers between starting and ending values
149 for my $i ( $starting .. $ending ) {
150  
151 # Check if current number is divisible by any of these factors: 15, 3 or itself
152 foreach my $factor ( @factors ) {
153 next unless $_ * $i == $i;
154 push( @{ $results[$factor] },"$i" );
155 }
156 else {
157 push( @{ $results[0] },"$i" );
158 }
159  
160 $count++;
161 }
162  
163 return \@results;
164 }
165  
166 # Define arrays containing factors to check for each result type
167 my %fizz = ( 15 );
168 my %buzz = ( 3 );
169 my %self = ( 0 );
170  
171 # Call the fizz_buzz subroutine with appropriate parameters
172 print Dumper( \@result );
173  
174 =head2 LEEJO (snippet from obs-studio/libobs/obs.c)
175  
176 static void stop_audio(void)
177 {
178 struct obs_core_audio *audio = &obs->audio;
179  
180 if (audio->audio) {
181 audio_output_close(audio->audio);
182 audio->audio = NULL;
183 }
184 }
185  
186 =head2 LEEJO (only compiles on a Friday)
187  
188 # general idea shamelessly stolen from Randal L. Schwartz:
189 # https://www.perlmonks.org/index.pl?node_id=44722
190  
191 use Time::Piece;
192  
193 BEGIN {
194 *f = (localtime->wdayname eq 'Fri')
195 ? sub() {}
196 : sub {};
197 }
198  
199 f/1;#/+
200  
201 =head2 MIKESTOK (soundex "joke")
202  
203 sub Soundex
204 {
205 local ($_, $f) = shift;
206  
207 y;a-z;A-Z;;y;A-Z;;cd;$_ ne q???do{($f)=m;^(.);;s;$f+;;;
208 y;AEHIOUWYBFPVCGJKQSXZDTLMNR;00000000111122222222334556;;
209 y;;;cs;y;0;;d;s;^;$f;;s;$;0000;;m;(^.{4});;$1;}:q;;;
210 }
211  
212 =head2 NERDVANA (delorean_ options.pl)
213  
214 GetOptions(
215 'help|h|?' => sub { pod2usage(1) },
216 'serial-dev|d=s' => \my $opt_serial_dev= '/dev/delorean',
217 'socket|S=s' => \my $opt_socket= '/run/uctl-daemon.sock',
218 ) or pod2usage(2);
219  
220 =head2 SLU (MAZE.BAS)
221  
222 10 PRINT CHR$(205.5+RND(1));:GOTO 10
223  
224 =head2 SLU (schwartzian_transform.pl)
225  
226  
227 #!/usr/bin/env perl
228 # https://en.wikipedia.org/wiki/Schwartzian_transform
229 # Sort list of words according to word length
230  
231 print "$_\n" foreach
232 map { $_->[0] }
233 sort { $a->[1] <=> $b->[1] or $a->[0] cmp $b->[0] }
234 map { [$_, length($_)] }
235 qw(demo of schwartzian transform);
236  
237 =head2 LIST OF WORKSHOPS / CONFERENCES
238  
239 A full list of the workshops and conferences this project was shot at
240  
241 =over
242  
243 =item Alpine Perl Workshop (2016)
244  
245 =item FOSDEM (2024)
246  
247 =item German Perl Workshop (2019)
248  
249 =item German Perl and Raku Workshop (2022, 2023, 2024, 2025)
250  
251 =item Les Journées Perl (2017, 2019)
252  
253 =item London Perl Workshop (2015, 2016, 2019)
254  
255 =item PerlCon (2019)
256  
257 =item Swiss Perl Workshop (2015, 2017, 2018, 2019)
258  
259 =item The Perl Conference [EU] (2017, 2018)
260  
261 =item The Perl Conference [NA] (2016, 2017)
262  
263 =item The Perl Toolchain Summit (2017)
264  
265 =item The Perl and Raku Conference [NA] (2023, 2024)
266  
267 =item Yet Another Perl Conference [EU] (2015, 2016)
268  
269 =back
270  
271 =head1 THANKS
272  
273 Thanks to all who contributed a snippet
274  
275 =head1 SEE ALSO
276  
277 L<https://www.formulanon.com/glue>
278  
279 L<https://www.youtube.com/watch?v=OXcHLAL_luU>
280  
281 L<https://leejo.github.io/acme-glue-talk/presentation.html#1>
282  
283 =head1 AUTHOR
284  
285 Lee Johnson - C<leejo@cpan.org>
286  
287 =head1 LICENCE
288  
289 This library is free software; you can redistribute it and/or modify it under
290 the same terms as Perl itself. If you would like to contribute documentation,
291 features, bug fixes, or anything else then please raise an issue / pull request:
292  
293 https://github.com/leejo/acme-glue
294  
295 All photos © Lee Johnson
296  
297 =cut
298  
299 1;