Matt's PSGI Archive
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Matt's PSGI Archive

on

  • 20,232 views

A talk I gave at YAPC in Kiev

A talk I gave at YAPC in Kiev

Statistics

Views

Total Views
20,232
Views on SlideShare
20,213
Embed Views
19

Actions

Likes
0
Downloads
6
Comments
0

5 Embeds 19

https://twitter.com 6
http://lanyrd.com 6
http://community.sitepoint.com 5
http://feeds.feedburner.com 1
http://www.feedspot.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Matt's PSGI Archive Presentation Transcript

  • 1. Matt's PSGI Archive
  • 2. I blame Leo Lapworth
  • 3. London.pm Tech Meet
  • 4. 14th August
  • 5. Talking about PSGI
  • 6. Leo Mentioned Matt Wright
  • 7. I Tweeted
  • 8. Some history
  • 9. 1995
  • 10. Matt's Script Archive
  • 11. Most popular Perl web site on the web
  • 12. Most well- known Perl code on the internet
  • 13. FormMail
  • 14. Most widely installed Perl program on the internet
  • 15. Most popular spamming tool on the internet
  • 16. Terrible example of Perl programming
  • 17. Popular != Good
  • 18. People “learn” Perl from copying Matt's code
  • 19. People learn “Perl” from copying Matt's code
  • 20. 2001
  • 21. Not Matt's Scripts
  • 22. New versions of Matt's scripts
  • 23. Fewer Bugs
  • 24. Fewer Security Holes
  • 25. Higher quality code
  • 26. Coding constraints
  • 27. Targeting cheap hosting plans
  • 28. 1. No CPAN Modules
  • 29. 2. Perl 5.004_04
  • 30. (First version to include CGI.pm)
  • 31. Interesting challenge
  • 32. “Interesting” challenge
  • 33. Results not completely satisfactory
  • 34. No Template Toolkit
  • 35. No Email::*
  • 36. Not best practice
  • 37. (Even for 2001)
  • 38. 2012
  • 39. NMS looks embarrassing
  • 40. Perl web programming has changed a lot
  • 41. People still find Matt's code
  • 42. People still “learn” “Perl” from Matt's code
  • 43. Some people are directed to nms project
  • 44. Not best practice
  • 45. Mojolicious blog posts
  • 46. Matt targeted cheap hosting plans
  • 47. nms targeted cheap hosting plans
  • 48. Cheap hosting plans are not CPAN friendly
  • 49. Unintended consequences
  • 50. nms discourages CPAN use
  • 51. Dilemma
  • 52. Best Practice vs Easy to install
  • 53. Cheap hosting plans still exist
  • 54. But do their users still use Perl/CGI?
  • 55. PHP
  • 56. nms still exists
  • 57. So I started thinking...
  • 58. Why not...
  • 59. ...rewrite Matt's scripts again?
  • 60. Using Modern Perl Best Practices
  • 61. CPAN
  • 62. PSGI
  • 63. Dancer Catalyst Mojolicious Web::Simple
  • 64. Template Email::* DBIx::Class
  • 65. Don't expect many users
  • 66. Simple examples
  • 67. Solutions to common problems
  • 68. Entry-level web programming in Perl
  • 69. Some of this stuff is ridiculously easy
  • 70. text_clock
  • 71. rand_text
  • 72. About five lines of code
  • 73. Others were overcomplicated by Matt's implementation
  • 74. guestbook wwwboard
  • 75. Both far easier if you use a database
  • 76. 2013
  • 77. “Let's remove CGI.pm from Perl core”
  • 78. nms stops working on cheap hosting
  • 79. Matt's scripts carry on working just fine
  • 80. (Which is a little bit annoying)
  • 81. When will those cheap hosting plans upgrade to Perl 5.20?
  • 82. Probably in about 15 years
  • 83. Plenty of time to get people used to PSGI
  • 84. Simple examples look like a good idea
  • 85. Progress report
  • 86. Github
  • 87. github.com/davorg/matts-psgi-archive
  • 88. Four (simple) programs written
  • 89. countdown rand_image rand_text text_clock
  • 90. Others to follow soon
  • 91. (Probably by Christmas)
  • 92. Show us some code
  • 93. Remember I said it was really easy
  • 94. rand_text
  • 95. my $random_file = 'random.txt'; my $delimiter = "%%n"; get '/' => sub { open my $file, '<', get_file($random_file) or error $!; my @phrases; { local $/ = $delimiter; chomp(@phrases = <$file>); } my $phrase = @phrases[rand @phrases]; return $phrase; }; dance;
  • 96. rand_image
  • 97. my $img_dir = 'public/img'; get '/' => sub { opendir my $dir, $img_dir or die $!; my @imgs = grep { -f "$img_dir/$_" } readdir $dir; my $img = @imgs[rand @imgs]; return redirect "/img/$img"; }; get '/img/:img' => sub { return send_file 'img/' . params->{img}; }; dance;
  • 98. text_clock
  • 99. use Time::Piece; get '/' => sub { return date(); }; sub date { if (! $Display_Format) { $Display_Format = build_format(); } return localtime->strftime($Display_Format); }
  • 100. sub build_format { my @date_fmt; push @date_fmt, '%A' if $Display_Week_Day; push @date_fmt, '%B' if $Display_Month; push @date_fmt, '%d' if $Display_Month_Day; push @date_fmt, '%Y' if $Display_Year; push @date_fmt, '%H:%M:%S' if $Display_Time; push @date_fmt, '%Z' if $Display_Time_Zone; return join ' ', @date_fmt; }
  • 101. github.com/davorg/matts-psgi-archive
  • 102. Feel free to submit code
  • 103. Full replacements are good
  • 104. Patches to existing programs are good
  • 105. Documentation is good
  • 106. Any help is good
  • 107. github.com/davorg/matts-psgi-archive
  • 108. Dave Cross dave@perlhacks.com @davorg