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

חוברת הקורס
חוברת הקורסחוברת הקורס
חוברת הקורס
cp sec
 
Html Intro2
Html Intro2Html Intro2
Html Intro2
mlackner
 

What's hot (20)

Java programming-examples
Java programming-examplesJava programming-examples
Java programming-examples
 
Php array
Php arrayPhp array
Php array
 
JavaScript - Chapter 10 - Strings and Arrays
 JavaScript - Chapter 10 - Strings and Arrays JavaScript - Chapter 10 - Strings and Arrays
JavaScript - Chapter 10 - Strings and Arrays
 
חוברת הקורס
חוברת הקורסחוברת הקורס
חוברת הקורס
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1
 
slingmodels
slingmodelsslingmodels
slingmodels
 
Python programming : Strings
Python programming : StringsPython programming : Strings
Python programming : Strings
 
Css Specificity
Css SpecificityCss Specificity
Css Specificity
 
Javascript essentials
Javascript essentialsJavascript essentials
Javascript essentials
 
Javascript
JavascriptJavascript
Javascript
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
Variables & Data Types In Python | Edureka
Variables & Data Types In Python | EdurekaVariables & Data Types In Python | Edureka
Variables & Data Types In Python | Edureka
 
Core java
Core javaCore java
Core java
 
Hyper Text Mark-up Language
Hyper Text Mark-up Language Hyper Text Mark-up Language
Hyper Text Mark-up Language
 
Tablas en html
Tablas en htmlTablas en html
Tablas en html
 
Document object model
Document object modelDocument object model
Document object model
 
Html form tag
Html form tagHtml form tag
Html form tag
 
Javascript Basic
Javascript BasicJavascript Basic
Javascript Basic
 
Html 5 tutorial - By Bally Chohan
Html 5 tutorial - By Bally ChohanHtml 5 tutorial - By Bally Chohan
Html 5 tutorial - By Bally Chohan
 
Html Intro2
Html Intro2Html Intro2
Html Intro2
 

Viewers also liked (6)

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
 

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

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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
 
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
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Introducing Modern Perl