SlideShare a Scribd company logo
1 of 161
Introducing Modern Perl Dave Cross Magnum Solutions Ltd [email_address]
Modern Perl ,[object Object]
Achieved great popularity in the 1990s
“The duct tape of the internet”
Perl has moved on a lot since then
Many people's perceptions of Perl haven't
Modern Perl ,[object Object]
Surveying modern modules and techniques
A lot to cover
Only an overview
Plenty of pointers to more information
What We Will Cover ,[object Object]
DateTime
DBIx::Class
TryCatch
What We Will Cover ,[object Object]
autodie
Catalyst
PSGI/Plack
Schedule ,[object Object]
11:00 – Coffee break
13:00 – Lunch
14:00 – Begin
16:00 – Coffee break
17:00 – End
Resources ,[object Object]
Template Toolkit
Templates ,[object Object]
Advantages are well known
Standard look and feel (static/dynamic)
Reusable components
Separation of code logic from display logic
Different skill-sets (HTML vs Perl)
DIY Templating ,[object Object]
See perlfaq4
“How can I expand variables in text strings?”
DIY Templating ,[object Object]
Don't do that
Templating Options ,[object Object]
Text::Template, HTML::Template, Mason, Template Toolkit
Many, many more
Questions to consider ,[object Object]
Template language
Template Toolkit ,[object Object]
Very powerful
Both web and non-web
Simple template language
Plugins give access to much of CPAN
Can use Perl code if you want ,[object Object]
Good Book Too!
The Template Equation ,[object Object]
Data + Alternative Template = Alternative Output
Different views of the same data
Only the template changes
Simple TT Example ,[object Object]
html.tt ,[object Object]
text.tt ,[object Object]
Adding New Formats ,[object Object]
Just add new output template
Perl programmer need not be involved
Equation Revisited ,[object Object]
DateTime
Dates & Times ,[object Object]
time  – seconds since 1st Jan 1970
localtime  – convert to human-readable
timelocal  (in Time::Local) – inverse of localtime
strftime  (in POSIX) – formatting dates and times
Dates & Times on CPAN ,[object Object]
Dozens of date/time modules on CPAN
Date::Manip is almost never what you want
Date::Calc, Date::Parse, Class::Date, Date::Simple, etc
Which one do you choose?
Perl DateTime Project ,[object Object]
"The DateTime family of modules present a unified way to handle dates and times in Perl"
"unified" is good
Dozens of modules that work together in a consistent fashion
Using DateTime ,[object Object]
Using DateTime ,[object Object]
Arithmetic ,[object Object]
For date arithmetic you need a duration
Number of years, weeks, days, etc
Arithmetic ,[object Object]
Formatting Output ,[object Object]
strftime uses UNIX standards
Control input format with DateTime::Format::Strptime
Parsing & Formatting ,[object Object]
DateTime::Format::HTTP
DateTime::Format::MySQL
DateTime::Format::Excel
DateTime::Format::Baby ,[object Object]
Alternative Calendars ,[object Object]
DateTime::Calendar::Julian
DateTime::Calendar::Hebrew
DateTime::Calendar::Mayan
DateTime::Fiction::JRRTolkien::Shire
Calendar Examples ,[object Object]
use DateTime::Fiction::JRRTolkien::Shire; my $dt =    DateTime::Fiction::JRRTolkien::Shire->now; say $dt->on_date; # Trewsday 14 Afterlithe 7474
DBIx::Class
Object Relational Mapping ,[object Object]
Tables (relations) map onto classes
Rows (tuples) map onto objects
Columns (attributes) map onto attributes
Don't write SQL
SQL Is Tedious ,[object Object]
Select all the details of this row
Select something about related tables
Update this row with these values
Insert a new record with these values
Delete this record
Replacing SQL ,[object Object]
SELECT * FROM  my_table WHERE  my_id = 10
and then dealing with the prepare/execute/fetch code
Replacing SQL ,[object Object]
use My::Object; # warning! not a real orm my $obj = My::Object->retrieve(10)
Or something similar
Writing An ORM Layer ,[object Object]
Each class needs an associated table
Each class needs a list of columns
Create simple SQL for basic CRUD operations
Don't do that
Perl ORM Options ,[object Object]
Class::DBI
Rose::DB::Object
ORLite
DBIx::Class ,[object Object],[object Object]
DBIx::Class ,[object Object]
Learning from problems in Class::DBI
More flexible
More powerful
DBIx::Class Example ,[object Object]
Three tables
artist (artistid, name)
cd (cdid, artist, title)
track (trackid, cd, title)
Main Schema ,[object Object]
Music/DB.pm ,[object Object]
Object Classes - Artist ,[object Object],[object Object]
Object Classes- CD ,[object Object],[object Object]
Inserting Artists ,[object Object]
Inserting CDs ,[object Object],[object Object]
Inserting CDs ,[object Object],[object Object]
Retrieving Data ,[object Object],[object Object]
Searching for Data ,[object Object]
Alternatives ,[object Object],[object Object]
Searching for Data ,[object Object],[object Object]
Don't Repeat Yourself ,[object Object]
Information is repeated
Columns and relationships defined in the database schema
Columns and relationships defined in class definitions
Repeated Information ,[object Object]
Repeated Information ,[object Object]
Database Metadata ,[object Object]
Just tables and columns
No relationships. No constraints
You may as well make each column VARCHAR(255)
Database Metadata ,[object Object]
It's what your database is for
It's what your database does best
No Metadata (Excuse 1) ,[object Object]
Nonsense
All data will be shared eventually

More Related Content

What's hot

PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2
Kumar
 

What's hot (20)

PHP and Mysql
PHP and MysqlPHP and Mysql
PHP and Mysql
 
Javascript Basic
Javascript BasicJavascript Basic
Javascript Basic
 
PHP Data Objects
PHP Data ObjectsPHP Data Objects
PHP Data Objects
 
PHP Cookies and Sessions
PHP Cookies and SessionsPHP Cookies and Sessions
PHP Cookies and Sessions
 
Class 3 - PHP Functions
Class 3 - PHP FunctionsClass 3 - PHP Functions
Class 3 - PHP Functions
 
PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2
 
Php string function
Php string function Php string function
Php string function
 
Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript Basics
 
Php sessions
Php sessionsPhp sessions
Php sessions
 
Php
PhpPhp
Php
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
 
Html5 and-css3-overview
Html5 and-css3-overviewHtml5 and-css3-overview
Html5 and-css3-overview
 
Php array
Php arrayPhp array
Php array
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Loops in java script
Loops in java scriptLoops in java script
Loops in java script
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
 
Object Vs Data Structure - Clean code chapter6
Object Vs Data Structure - Clean code chapter6Object Vs Data Structure - Clean code chapter6
Object Vs Data Structure - Clean code chapter6
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
SQL
SQLSQL
SQL
 

Viewers also liked

Database Programming with Perl and DBIx::Class
Database Programming with Perl and DBIx::ClassDatabase Programming with Perl and DBIx::Class
Database Programming with Perl and DBIx::Class
Dave Cross
 
perl usage at database applications
perl usage at database applicationsperl usage at database applications
perl usage at database applications
Joe Jiang
 

Viewers also liked (7)

Database Programming with Perl and DBIx::Class
Database Programming with Perl and DBIx::ClassDatabase Programming with Perl and DBIx::Class
Database Programming with Perl and DBIx::Class
 
perl usage at database applications
perl usage at database applicationsperl usage at database applications
perl usage at database applications
 
DBI Advanced Tutorial 2007
DBI Advanced Tutorial 2007DBI Advanced Tutorial 2007
DBI Advanced Tutorial 2007
 
Working with databases
Working with databasesWorking with databases
Working with databases
 
Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in Perl
 
Efficient Shared Data in Perl
Efficient Shared Data in PerlEfficient Shared Data in Perl
Efficient Shared Data in Perl
 
Perl Introduction
Perl IntroductionPerl Introduction
Perl Introduction
 

Similar to Introducing Modern Perl

Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8
Tatsuhiko Miyagawa
 
Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP
yucefmerhi
 
Power Theming
Power ThemingPower Theming
Power Theming
drkdn
 
P H P Part I I, By Kian
P H P  Part  I I,  By  KianP H P  Part  I I,  By  Kian
P H P Part I I, By Kian
phelios
 
course slides -- powerpoint
course slides -- powerpointcourse slides -- powerpoint
course slides -- powerpoint
webhostingguy
 

Similar to Introducing Modern Perl (20)

Perl Teach-In (part 1)
Perl Teach-In (part 1)Perl Teach-In (part 1)
Perl Teach-In (part 1)
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl Techniques
 
Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8
 
Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted NewardArchitecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
 
Introduction to Modern Perl
Introduction to Modern PerlIntroduction to Modern Perl
Introduction to Modern Perl
 
How Xslate Works
How Xslate WorksHow Xslate Works
How Xslate Works
 
Power Theming
Power ThemingPower Theming
Power Theming
 
Bioinformatica 10-11-2011-p6-bioperl
Bioinformatica 10-11-2011-p6-bioperlBioinformatica 10-11-2011-p6-bioperl
Bioinformatica 10-11-2011-p6-bioperl
 
Cena-DTA PHP Conference 2011 Slides
Cena-DTA PHP Conference 2011 SlidesCena-DTA PHP Conference 2011 Slides
Cena-DTA PHP Conference 2011 Slides
 
Create a web-app with Cgi Appplication
Create a web-app with Cgi AppplicationCreate a web-app with Cgi Appplication
Create a web-app with Cgi Appplication
 
P H P Part I I, By Kian
P H P  Part  I I,  By  KianP H P  Part  I I,  By  Kian
P H P Part I I, By Kian
 
course slides -- powerpoint
course slides -- powerpointcourse slides -- powerpoint
course slides -- powerpoint
 
Php
PhpPhp
Php
 
Perl Presentation
Perl PresentationPerl Presentation
Perl Presentation
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter Scott
 
Slick Data Sharding: Slides from DrupalCon London
Slick Data Sharding: Slides from DrupalCon LondonSlick Data Sharding: Slides from DrupalCon London
Slick Data Sharding: Slides from DrupalCon London
 
Writing webapps with Perl Dancer
Writing webapps with Perl DancerWriting webapps with Perl Dancer
Writing webapps with Perl Dancer
 
Ods Markup And Tagsets: A Tutorial
Ods Markup And Tagsets: A TutorialOds Markup And Tagsets: A Tutorial
Ods Markup And Tagsets: A Tutorial
 

More from Dave Cross

Object-Oriented Programming with Perl and Moose
Object-Oriented Programming with Perl and MooseObject-Oriented Programming with Perl and Moose
Object-Oriented Programming with Perl and Moose
Dave Cross
 

More from Dave Cross (20)

Measuring the Quality of Your Perl Code
Measuring the Quality of Your Perl CodeMeasuring the Quality of Your Perl Code
Measuring the Quality of Your Perl Code
 
Apollo 11 at 50 - A Simple Twitter Bot
Apollo 11 at 50 - A Simple Twitter BotApollo 11 at 50 - A Simple Twitter Bot
Apollo 11 at 50 - A Simple Twitter Bot
 
Monoliths, Balls of Mud and Silver Bullets
Monoliths, Balls of Mud and Silver BulletsMonoliths, Balls of Mud and Silver Bullets
Monoliths, Balls of Mud and Silver Bullets
 
The Professional Programmer
The Professional ProgrammerThe Professional Programmer
The Professional Programmer
 
I'm A Republic (Honest!)
I'm A Republic (Honest!)I'm A Republic (Honest!)
I'm A Republic (Honest!)
 
Web Site Tune-Up - Improve Your Googlejuice
Web Site Tune-Up - Improve Your GooglejuiceWeb Site Tune-Up - Improve Your Googlejuice
Web Site Tune-Up - Improve Your Googlejuice
 
Modern Perl Web Development with Dancer
Modern Perl Web Development with DancerModern Perl Web Development with Dancer
Modern Perl Web Development with Dancer
 
Freeing Tower Bridge
Freeing Tower BridgeFreeing Tower Bridge
Freeing Tower Bridge
 
Modern Perl Catch-Up
Modern Perl Catch-UpModern Perl Catch-Up
Modern Perl Catch-Up
 
Error(s) Free Programming
Error(s) Free ProgrammingError(s) Free Programming
Error(s) Free Programming
 
Medium Perl
Medium PerlMedium Perl
Medium Perl
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
 
Improving Dev Assistant
Improving Dev AssistantImproving Dev Assistant
Improving Dev Assistant
 
Conference Driven Publishing
Conference Driven PublishingConference Driven Publishing
Conference Driven Publishing
 
Conference Driven Publishing
Conference Driven PublishingConference Driven Publishing
Conference Driven Publishing
 
TwittElection
TwittElectionTwittElection
TwittElection
 
Perl in the Internet of Things
Perl in the Internet of ThingsPerl in the Internet of Things
Perl in the Internet of Things
 
Return to the Kingdom of the Blind
Return to the Kingdom of the BlindReturn to the Kingdom of the Blind
Return to the Kingdom of the Blind
 
Github, Travis-CI and Perl
Github, Travis-CI and PerlGithub, Travis-CI and Perl
Github, Travis-CI and Perl
 
Object-Oriented Programming with Perl and Moose
Object-Oriented Programming with Perl and MooseObject-Oriented Programming with Perl and Moose
Object-Oriented Programming with Perl and Moose
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Introducing Modern Perl