add Antiquated Perl slides as POD, delete takahashi code
[catagits/Web-Simple.git] / lib / Web / Simple / AntiquatedPerl.pod
1 =head1 NAME
2
3 Web::Simple::AntiquatedPerl - the slides from the talk
4
5 =head1 WHAT?
6
7 Web::Simple was originally introduced in a talk at the Italian Perl Workshop,
8 entitled Antiquated Perl.
9
10 The video is available on the Shadowcat site: <http://www.shadowcat.co.uk/archive/conference-video/ipw-2009/antiquated>
11
12 If you don't particularly want to watch me confusing a bunch of Italian perl
13 mongers, the slides are reproduced below.
14
15 =head1 SLIDES
16
17   Antiquated
18   Perl
19   ----
20   Modern
21   Perl?
22   ----
23   Post
24   Modern
25   Perl
26   ----
27   Enlightened
28   Perl
29   ----
30   everybody
31   knows
32   ----
33   Catalyst
34   Moose
35   DBIx::Class
36   ----
37   Modern
38   Perl?
39   ----
40   perl5
41   v10
42   ----
43     given ($x) {
44       when (3) {
45     ...
46   ----
47   ~~
48   ----
49   what's the
50   opposite?
51   ----
52   Old
53   Perl?
54   ----
55   if it 
56   works
57   ----
58   Legacy
59   Perl?
60   ----
61   not
62   interesting
63   ----
64   Stupid
65   Perl
66   ----
67   *$&^*(^
68   FormMail.PL
69   ----
70   Antiquated
71   Perl
72   ----
73   Antique
74   ----
75   Old *and*
76   beautiful
77   ----
78   Simple
79   Elegant
80   ----
81     $|++
82   ----
83     use IO::Handle;
84     STDOUT->autoflush(1);
85   ----
86   it's core.
87   it's fine.
88   ----
89   but why
90   think?
91   ----
92     select((select(FOO),$|++)[0])
93   ----
94     (select(FOO),$|++)
95     ->
96     ($old_selected_fh,$|)
97   ----
98     (select(FOO),$|++)[0]
99     ->
100     $old_select_fh
101   ----
102     select((select(FOO),$|++)[0])
103     ->
104     use IO::Handle;
105     FOO->autoflush(1)
106   ----
107   ~~
108   ----
109     ~~@x
110   ----
111     ~(~(@x))
112   ----
113   bitwise
114   negation
115   ----
116   so ...
117   ----
118     ~@x
119     ->
120     ~(scalar @x)
121   ----
122     ~~$number
123     ->
124     $number
125   ----
126     ~~@x
127     ->
128     scalar @x
129   ----
130     perl -MMoose -e'print ~~keys %INC'
131     84
132   ----
133   overload::constant
134   ----
135   lets you
136   affect
137   parsing
138   ----
139   numbers
140   strings
141   ----
142   q qq qr
143   t s qw
144   ----
145   i18n.pm
146   ----
147   ~~"$foo bar"
148   loc("_[0] bar", $foo)
149   ----
150   for
151   ----
152     for ($foo) {
153       /bar/ and ...
154   ----
155     for ($foo) {
156       /bar/ and return do {
157         <code here>
158       }
159   ----
160     /foo/gc
161   ----
162     /\Gbar/gc
163   ----
164     sub parse {
165       my ($self, $str) = @_;
166       for ($str) {
167         /match1/gc and return
168           $self->_subparse_1($_)
169   ----
170     sub _subparse_1 {
171       my ($self) = @_;
172       for ($_[1]) {
173         /\Gsubmatch1/gc ...
174   ----
175   prototypes
176   ----
177     sub foo (&) {
178   ----
179     foo {
180       ...
181     };
182   ----
183     prototype \&foo
184   ----
185   typeglobs
186   ----
187     *{"${package}::${name}"}
188       = sub { ... }
189   ---- 
190     local
191   ----
192     local $_
193   ----
194     local *Carp::croak
195       = \&Carp::confess;
196   ----
197     do {
198       local (@ARGV, $/) = $file;
199       <>
200     }
201   ----
202   strict
203   and
204   warnings
205   ----
206     strict->import
207   ----
208   affects
209   compilation
210   scope
211   ----
212     sub strict_and_warnings::import {
213       strict->import;
214       warnings->import;
215     }
216   ----
217     use strict_and_warnings;
218   ----
219   $^H
220   %^H
221   ----
222     $^H |= 0x120000;
223     $^H{'foo'}
224       = bless($foo, 'My::Foo');
225   ----
226     sub My::Foo::DESTROY {
227   ----
228     delete ${$package}{myimport}
229   ----
230   B::Hooks::EndOfScope
231   ----
232   tie
233   ----
234     tie $var, 'Foo';
235   ----
236     sub FETCH
237     sub STORE
238   ----
239   Scalar
240   Array
241   Hash
242   Handle
243   ----
244   now ...
245   ----
246   mst: destruction
247   testing technology
248   since March 1983
249   ----
250   3 days
251   old
252   ----
253   2 weeks
254   early
255   ----
256   incubator
257   ----
258   glass box
259   plastic tray
260   heater
261   ----
262   design
263   flaw
264   ----
265   BANG
266   ----
267   so ...
268   ----
269   interesting
270   fact
271   ----
272   prototypes
273   only warn
274   when parsed
275   ----
276   error when
277   compiled
278   ----
279   so ...
280   ----
281     dispatch [
282       sub (GET + /) { ... },
283       sub (GET + /user/*) { ... }
284     ];
285   ----
286     foreach my $sub (@$dispatch) {
287       my $proto = prototype $sub;
288       $parser->parse($proto);
289       ...
290   ----
291     PARSE: { do {
292       push @match, $self->_parse_spec_section($spec)
293         or $self->_blam("Unable to work out what the next section is");
294       last PARSE if (pos == length);
295       /\G\+/gc or $self->_blam('Spec sections must be separated by +');
296     } until (pos == length) };
297   ----
298     sub _blam {
299       my ($self, $error) = @_;
300       my $hat = (' ' x pos).'^';
301       die "Error parsing dispatch specification: ${error}\n
302     ${_}
303     ${hat} here\n";
304     }
305   ----
306     Error parsing ...
307     GET+/foo
308        ^ here
309   ----
310     sub (GET + /user/*) {
311      my ($self, $user) = @_;
312   ----
313   I hate
314   fetching
315   $self
316   ----
317     *{"${app}::self"}
318       = \${"${app}::self"};
319   ----
320   use vars
321   ----
322     sub _run_with_self {
323       my ($self, $run, @args) = @_;
324       my $class = ref($self);
325       no strict 'refs';
326       local *{"${class}::self"} = \$self;
327       $self->$run(@args);
328     }
329   ----
330   HTML
331   output
332   ----
333   templates
334   ----
335   HTML is
336   NOT TEXT
337   ----
338     <div>,
339       $text,
340     </div>;
341   ----
342   <div>
343   ----
344   <$fh>
345   ----
346     tie *{"${app}::${name}"},
347       'XML::Tags::TIEHANDLE',
348       "<${name}>";
349   ----
350     sub TIEHANDLE { my $str = $_[1]; bless \$str, $_[0] }
351     sub READLINE { ${$_[0]} }
352   ----
353     sub DESTROY {
354       my ($into, @names) = @$_[0];
355       no strict 'refs';
356       delete ${$into}{$_}
357         for @names;
358     }
359   ----
360   </div>
361   ----
362   glob('/div');
363   ----
364     *CORE::GLOBAL::glob
365       = sub { ... };
366   ----
367     delete
368       ${CORE::GLOBAL::}{glob};
369   ----
370     sub foo {
371       use XML::Tags qw(div);
372       <div>, "foo!", </div>;
373     }
374   ----
375   what about
376   interpolation
377   ----
378     my $stuff = 'foo"bar';
379     <a href="$stuff">
380   ----
381   hmm ...
382   ----
383   overload::constant!
384   ----
385     glob('a href="'.$stuff.'"');
386   ----
387     glob(
388       bless(\'a href="', 'MagicTag')
389       .$stuff
390       .bless(\'"', 'MagicTag')
391     )
392   ----
393     use overload
394       '.' => 'concat';
395   
396     sub concat {
397   ----
398   hooking
399   it up
400   ----
401     sub (.html) {
402       filter_response {
403         $self->render_html($_[1])
404       }
405     }
406   ----
407     bless(
408       $_[1],
409       'Web::Simple::ResponseFilter'
410     );
411   ----
412     if ($self->_is_response_filter($result)) {
413       return $self->_run_with_self(
414         $result,
415         $self->_run_dispatch_for($new_env, \@disp)
416       );
417     }
418   ----
419   and the result?
420   ----
421    goto &demo;
422   ----
423   questions?
424   ----
425   thank
426   you
427
428 =head1 AUTHOR
429
430 Matt S. Trout <mst@shadowcat.co.uk>
431
432 =head1 COPYRIGHT
433
434 Copyright (c) 2010 Matt S. Trout <mst@shadowcat.co.uk>
435
436 =head1 LICENSE
437
438 This text may be distributed under the GPL (v2 or later), the Artistic License
439 (v1 or later), the Creative Commons Attribution (CC BY v3 or later), the
440 Mozilla Public License (v1 or later, in honour of the license of the
441 takahashi.xul system I used to write these slides originally), or the
442 WTFPL (see <http://sam.zoy.org/wtfpl/COPYING>).
443
444 If you'd like me to add another license, please ask.
445
446 =cut