SlideShare a Scribd company logo
1 of 74
Download to read offline
Maintaining Code While Staying Sane Peter Scott O’Reilly School of Technology February 2011
Dealing With Legacy Perl ,[object Object],[object Object],[object Object],[object Object]
Why So Many Ugly Perl Programs? ,[object Object],[object Object]
The “DWIM” Myth ,[object Object],[object Object],[object Object],[object Object]
The “Prototyping Only” Myth ,[object Object],[object Object],[object Object],[object Object]
The “$@%*!” Myth ,[object Object],[object Object],[object Object],[object Object]
Find the Author(s)! ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What Are You Dealing With? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Maintainability ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Performance ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Brevity ,[object Object],[object Object]
Job Security ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Testing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tests are Real Programs, Too ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Testing Web Applications ,[object Object],[object Object],[object Object],[object Object]
Web Testing Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Modern Web Testing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Layout ,[object Object],[object Object],[object Object],[object Object],[object Object]
Before  perltidy ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
After  perltidy ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
After  perltidy ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Analysis ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Devel::NYTProf ,[object Object],[object Object],[object Object]
Devel::NYTProf
What to Look Out For in Inherited Code ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Documentation Hound ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Documentation Hound ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Documentation Hound Cure ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Documentation Hound Cure ,[object Object],[object Object],[object Object],[object Object]
String Manipulation, BASIC-Style ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
…  i.e., Without Regexes ,[object Object]
Nice Formatting, But… ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Nice Formatting, But… ,[object Object]
Too Much Time on Their Hands ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Too Much Time on Their Hands ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Too Much Time on Their Hands ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],Too Much Time on Their Hands To: santa.claus@north.pole From: johnny@home Subject: I've Been Good Dear Santa For Christmas I would like: Perl 6 Thank you ,[object Object]
Way Too Much Time On Their hands ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],The Perils of Cut and Paste # But now use only $mon  and $mday...
[object Object],[object Object],The Perils of Cut and Paste
[object Object],[object Object],The Perils of Cut and Paste
[object Object],[object Object],[object Object],The Perils of Cut and Paste
Scope? What is This Thing You Call Scope? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Scope Ignorance Cure ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Monolithic Madness ,[object Object],[object Object],[object Object],[object Object],[object Object]
Monolithic Madness Cure ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Perl from ??? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Perl from C ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Perl from C ,[object Object]
Perl from ??? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Perl from FORTRAN ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Perl from FORTRAN ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Perl from ??? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Perl from COBOL ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Perl from COBOL ,[object Object],[object Object],[object Object],[object Object]
Perl from ??? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Perl from BASIC ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Perl from BASIC ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Cargo Cult Perl ,[object Object]
Cargo Cult Perl use CGI;
Comment Code Smells ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Line Editing ,[object Object],[object Object],[object Object],[object Object]
Consolidate Variables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Consolidate Variables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Consolidate Variables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Consolidate Variables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Line Editing ,[object Object],[object Object],[object Object],[object Object]
Line Editing ,[object Object],[object Object],[object Object]
Line Editing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Line Editing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Line Editing ,[object Object],[object Object],[object Object],[object Object]
use strict ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
use warnings ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Commonly Neglected Modules ,[object Object],[object Object],[object Object]

More Related Content

What's hot

LPW: Beginners Perl
LPW: Beginners PerlLPW: Beginners Perl
LPW: Beginners PerlDave Cross
 
Beginning Perl
Beginning PerlBeginning Perl
Beginning PerlDave Cross
 
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 Appplicationolegmmiller
 
Php Calling Operators
Php Calling OperatorsPhp Calling Operators
Php Calling Operatorsmussawir20
 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of SmartmatchAndrew Shitov
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1Dave Cross
 
Perl Xpath Lightning Talk
Perl Xpath Lightning TalkPerl Xpath Lightning Talk
Perl Xpath Lightning Talkddn123456
 
Perl 5.10 for People Who Aren't Totally Insane
Perl 5.10 for People Who Aren't Totally InsanePerl 5.10 for People Who Aren't Totally Insane
Perl 5.10 for People Who Aren't Totally InsaneRicardo Signes
 
Perl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel ComputingPerl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel ComputingAndrew Shitov
 
You Can Do It! Start Using Perl to Handle Your Voyager Needs
You Can Do It! Start Using Perl to Handle Your Voyager NeedsYou Can Do It! Start Using Perl to Handle Your Voyager Needs
You Can Do It! Start Using Perl to Handle Your Voyager NeedsRoy Zimmer
 
The Basics Of Page Creation
The Basics Of Page CreationThe Basics Of Page Creation
The Basics Of Page CreationWildan Maulana
 
PHP7. Game Changer.
PHP7. Game Changer. PHP7. Game Changer.
PHP7. Game Changer. Haim Michael
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to PerlDave Cross
 
Evolving Software with Moose
Evolving Software with MooseEvolving Software with Moose
Evolving Software with MooseDave Cross
 
Improving Dev Assistant
Improving Dev AssistantImproving Dev Assistant
Improving Dev AssistantDave Cross
 
Intermediate Perl
Intermediate PerlIntermediate Perl
Intermediate PerlDave Cross
 

What's hot (20)

LPW: Beginners Perl
LPW: Beginners PerlLPW: Beginners Perl
LPW: Beginners Perl
 
Beginning Perl
Beginning PerlBeginning Perl
Beginning Perl
 
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
 
Abuse Perl
Abuse PerlAbuse Perl
Abuse Perl
 
Php Calling Operators
Php Calling OperatorsPhp Calling Operators
Php Calling Operators
 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of Smartmatch
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1
 
Perl6 grammars
Perl6 grammarsPerl6 grammars
Perl6 grammars
 
Perl Xpath Lightning Talk
Perl Xpath Lightning TalkPerl Xpath Lightning Talk
Perl Xpath Lightning Talk
 
Perl 5.10 for People Who Aren't Totally Insane
Perl 5.10 for People Who Aren't Totally InsanePerl 5.10 for People Who Aren't Totally Insane
Perl 5.10 for People Who Aren't Totally Insane
 
Further Php
Further PhpFurther Php
Further Php
 
Perl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel ComputingPerl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel Computing
 
You Can Do It! Start Using Perl to Handle Your Voyager Needs
You Can Do It! Start Using Perl to Handle Your Voyager NeedsYou Can Do It! Start Using Perl to Handle Your Voyager Needs
You Can Do It! Start Using Perl to Handle Your Voyager Needs
 
The Basics Of Page Creation
The Basics Of Page CreationThe Basics Of Page Creation
The Basics Of Page Creation
 
PHP7. Game Changer.
PHP7. Game Changer. PHP7. Game Changer.
PHP7. Game Changer.
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
The Loop
The LoopThe Loop
The Loop
 
Evolving Software with Moose
Evolving Software with MooseEvolving Software with Moose
Evolving Software with Moose
 
Improving Dev Assistant
Improving Dev AssistantImproving Dev Assistant
Improving Dev Assistant
 
Intermediate Perl
Intermediate PerlIntermediate Perl
Intermediate Perl
 

Similar to Dealing with Legacy Perl Code - Peter Scott

Similar to Dealing with Legacy Perl Code - Peter Scott (20)

Perl Presentation
Perl PresentationPerl Presentation
Perl Presentation
 
Perl Moderno
Perl ModernoPerl Moderno
Perl Moderno
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 
Cena-DTA PHP Conference 2011 Slides
Cena-DTA PHP Conference 2011 SlidesCena-DTA PHP Conference 2011 Slides
Cena-DTA PHP Conference 2011 Slides
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 
Php Crash Course
Php Crash CoursePhp Crash Course
Php Crash Course
 
Why Python by Marilyn Davis, Marakana
Why Python by Marilyn Davis, MarakanaWhy Python by Marilyn Davis, Marakana
Why Python by Marilyn Davis, Marakana
 
PHP MySQL
PHP MySQLPHP MySQL
PHP MySQL
 
Method::Signatures
Method::SignaturesMethod::Signatures
Method::Signatures
 
Perl Teach-In (part 1)
Perl Teach-In (part 1)Perl Teach-In (part 1)
Perl Teach-In (part 1)
 
Gwt_Wouter1
Gwt_Wouter1Gwt_Wouter1
Gwt_Wouter1
 
Gwt wouter
Gwt wouterGwt wouter
Gwt wouter
 
What's new in Perl 5.10?
What's new in Perl 5.10?What's new in Perl 5.10?
What's new in Perl 5.10?
 
Php Loop
Php LoopPhp Loop
Php Loop
 
Basic PHP
Basic PHPBasic PHP
Basic PHP
 
Simple perl scripts
Simple perl scriptsSimple perl scripts
Simple perl scripts
 
Php 3 1
Php 3 1Php 3 1
Php 3 1
 
03 Php Array String Functions
03 Php Array String Functions03 Php Array String Functions
03 Php Array String Functions
 
Ch1(introduction to php)
Ch1(introduction to php)Ch1(introduction to php)
Ch1(introduction to php)
 
Perl Introduction
Perl IntroductionPerl Introduction
Perl Introduction
 

More from O'Reilly Media

2 3-2012 Take Control of iCloud
2 3-2012 Take Control of iCloud2 3-2012 Take Control of iCloud
2 3-2012 Take Control of iCloudO'Reilly Media
 
2 7-2012 Google how links boost rankings
2 7-2012 Google how links boost rankings2 7-2012 Google how links boost rankings
2 7-2012 Google how links boost rankingsO'Reilly Media
 
February 8, 2012 Webcast: 10 Things You Didn't Know About Google+
February 8, 2012 Webcast: 10 Things You Didn't Know About Google+February 8, 2012 Webcast: 10 Things You Didn't Know About Google+
February 8, 2012 Webcast: 10 Things You Didn't Know About Google+O'Reilly Media
 
12 13 what is desktop virtualization
12 13 what is desktop virtualization12 13 what is desktop virtualization
12 13 what is desktop virtualizationO'Reilly Media
 
Sept. 28, 2011 webcast become an expert google searcher in an hour stephan ...
Sept. 28, 2011 webcast become an expert google searcher in an hour   stephan ...Sept. 28, 2011 webcast become an expert google searcher in an hour   stephan ...
Sept. 28, 2011 webcast become an expert google searcher in an hour stephan ...O'Reilly Media
 
Oct. 4, 2011 webcast top 5 tips for building viral social web applications an...
Oct. 4, 2011 webcast top 5 tips for building viral social web applications an...Oct. 4, 2011 webcast top 5 tips for building viral social web applications an...
Oct. 4, 2011 webcast top 5 tips for building viral social web applications an...O'Reilly Media
 
Oct. 27, 2011 webcast practical and pragmatic application of pmi standards
Oct. 27, 2011 webcast practical and pragmatic application of pmi standardsOct. 27, 2011 webcast practical and pragmatic application of pmi standards
Oct. 27, 2011 webcast practical and pragmatic application of pmi standardsO'Reilly Media
 
Oct. 14, 2011 webcast ch7 subnets bruce hartpence
Oct. 14, 2011 webcast ch7 subnets bruce hartpenceOct. 14, 2011 webcast ch7 subnets bruce hartpence
Oct. 14, 2011 webcast ch7 subnets bruce hartpenceO'Reilly Media
 
Nov. 8, 2011 webcast desiging mobile interfaces by steven hoober
Nov. 8, 2011 webcast   desiging mobile interfaces by steven hooberNov. 8, 2011 webcast   desiging mobile interfaces by steven hoober
Nov. 8, 2011 webcast desiging mobile interfaces by steven hooberO'Reilly Media
 
Oct. 25. 2011 webcast conduct aninterview
Oct. 25. 2011 webcast   conduct aninterviewOct. 25. 2011 webcast   conduct aninterview
Oct. 25. 2011 webcast conduct aninterviewO'Reilly Media
 
Nov. 4, 2011 o reilly webcast-hbase- lars george
Nov. 4, 2011 o reilly webcast-hbase- lars georgeNov. 4, 2011 o reilly webcast-hbase- lars george
Nov. 4, 2011 o reilly webcast-hbase- lars georgeO'Reilly Media
 
Nov. 15, 2011 dani nordin talking to clients about drupal projects
Nov. 15, 2011 dani nordin talking to clients about drupal projectsNov. 15, 2011 dani nordin talking to clients about drupal projects
Nov. 15, 2011 dani nordin talking to clients about drupal projectsO'Reilly Media
 
What's New & Cool in Drupal 7
What's New & Cool in Drupal 7What's New & Cool in Drupal 7
What's New & Cool in Drupal 7O'Reilly Media
 
The Science of Social Media
The Science of Social MediaThe Science of Social Media
The Science of Social MediaO'Reilly Media
 
Apple earnings q4-2010
Apple earnings q4-2010Apple earnings q4-2010
Apple earnings q4-2010O'Reilly Media
 
Web 2.0 Expo Ny--How to Submit a Winning Proposal
Web 2.0 Expo Ny--How to Submit a Winning ProposalWeb 2.0 Expo Ny--How to Submit a Winning Proposal
Web 2.0 Expo Ny--How to Submit a Winning ProposalO'Reilly Media
 
O'Reilly Webcast: Architecting Applications For The Cloud
O'Reilly Webcast: Architecting Applications For The CloudO'Reilly Webcast: Architecting Applications For The Cloud
O'Reilly Webcast: Architecting Applications For The CloudO'Reilly Media
 
Active Facebook Users By Country & Region: August 2009
Active Facebook Users By Country & Region: August 2009Active Facebook Users By Country & Region: August 2009
Active Facebook Users By Country & Region: August 2009O'Reilly Media
 

More from O'Reilly Media (20)

2 3-2012 Take Control of iCloud
2 3-2012 Take Control of iCloud2 3-2012 Take Control of iCloud
2 3-2012 Take Control of iCloud
 
2 7-2012 Google how links boost rankings
2 7-2012 Google how links boost rankings2 7-2012 Google how links boost rankings
2 7-2012 Google how links boost rankings
 
February 8, 2012 Webcast: 10 Things You Didn't Know About Google+
February 8, 2012 Webcast: 10 Things You Didn't Know About Google+February 8, 2012 Webcast: 10 Things You Didn't Know About Google+
February 8, 2012 Webcast: 10 Things You Didn't Know About Google+
 
12 13 what is desktop virtualization
12 13 what is desktop virtualization12 13 what is desktop virtualization
12 13 what is desktop virtualization
 
Sept. 28, 2011 webcast become an expert google searcher in an hour stephan ...
Sept. 28, 2011 webcast become an expert google searcher in an hour   stephan ...Sept. 28, 2011 webcast become an expert google searcher in an hour   stephan ...
Sept. 28, 2011 webcast become an expert google searcher in an hour stephan ...
 
Oct. 4, 2011 webcast top 5 tips for building viral social web applications an...
Oct. 4, 2011 webcast top 5 tips for building viral social web applications an...Oct. 4, 2011 webcast top 5 tips for building viral social web applications an...
Oct. 4, 2011 webcast top 5 tips for building viral social web applications an...
 
Oct. 27, 2011 webcast practical and pragmatic application of pmi standards
Oct. 27, 2011 webcast practical and pragmatic application of pmi standardsOct. 27, 2011 webcast practical and pragmatic application of pmi standards
Oct. 27, 2011 webcast practical and pragmatic application of pmi standards
 
Oct. 14, 2011 webcast ch7 subnets bruce hartpence
Oct. 14, 2011 webcast ch7 subnets bruce hartpenceOct. 14, 2011 webcast ch7 subnets bruce hartpence
Oct. 14, 2011 webcast ch7 subnets bruce hartpence
 
Nov. 8, 2011 webcast desiging mobile interfaces by steven hoober
Nov. 8, 2011 webcast   desiging mobile interfaces by steven hooberNov. 8, 2011 webcast   desiging mobile interfaces by steven hoober
Nov. 8, 2011 webcast desiging mobile interfaces by steven hoober
 
Oct. 25. 2011 webcast conduct aninterview
Oct. 25. 2011 webcast   conduct aninterviewOct. 25. 2011 webcast   conduct aninterview
Oct. 25. 2011 webcast conduct aninterview
 
Nov. 4, 2011 o reilly webcast-hbase- lars george
Nov. 4, 2011 o reilly webcast-hbase- lars georgeNov. 4, 2011 o reilly webcast-hbase- lars george
Nov. 4, 2011 o reilly webcast-hbase- lars george
 
Nov. 15, 2011 dani nordin talking to clients about drupal projects
Nov. 15, 2011 dani nordin talking to clients about drupal projectsNov. 15, 2011 dani nordin talking to clients about drupal projects
Nov. 15, 2011 dani nordin talking to clients about drupal projects
 
What's New & Cool in Drupal 7
What's New & Cool in Drupal 7What's New & Cool in Drupal 7
What's New & Cool in Drupal 7
 
The Science of Social Media
The Science of Social MediaThe Science of Social Media
The Science of Social Media
 
Apple earnings q4-2010
Apple earnings q4-2010Apple earnings q4-2010
Apple earnings q4-2010
 
Web 2.0 Expo Ny--How to Submit a Winning Proposal
Web 2.0 Expo Ny--How to Submit a Winning ProposalWeb 2.0 Expo Ny--How to Submit a Winning Proposal
Web 2.0 Expo Ny--How to Submit a Winning Proposal
 
2009 Research Where
2009 Research Where2009 Research Where
2009 Research Where
 
O'Reilly Webcast: Architecting Applications For The Cloud
O'Reilly Webcast: Architecting Applications For The CloudO'Reilly Webcast: Architecting Applications For The Cloud
O'Reilly Webcast: Architecting Applications For The Cloud
 
Active Facebook Users By Country & Region: August 2009
Active Facebook Users By Country & Region: August 2009Active Facebook Users By Country & Region: August 2009
Active Facebook Users By Country & Region: August 2009
 
Web Squared
Web SquaredWeb Squared
Web Squared
 

Recently uploaded

Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfDaniel Santiago Silva Capera
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
Do we need a new standard for visualizing the invisible?
Do we need a new standard for visualizing the invisible?Do we need a new standard for visualizing the invisible?
Do we need a new standard for visualizing the invisible?SANGHEE SHIN
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7DianaGray10
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataCloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataSafe Software
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfAijun Zhang
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Websitedgelyza
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdfJamie (Taka) Wang
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 

Recently uploaded (20)

Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
Do we need a new standard for visualizing the invisible?
Do we need a new standard for visualizing the invisible?Do we need a new standard for visualizing the invisible?
Do we need a new standard for visualizing the invisible?
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataCloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdf
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Website
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 

Dealing with Legacy Perl Code - Peter Scott

  • 1. Maintaining Code While Staying Sane Peter Scott O’Reilly School of Technology February 2011
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60. Cargo Cult Perl use CGI;
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.

Editor's Notes

  1. Thank you for coming. Ask questions before break so I have time to research.
  2. Code written by someone else Or you, long enough ago Say a couple of weeks Why is Perl so susceptible?
  3. Perl’s motto is also a curse Perl is like English If you have William F. Buckley Jr., you also have Homer Simpson
  4. 100 line Perl script may not get the same attention to coding standards, documentation, or other methodology as a 1,000 line C program even though it deserves it just as much.
  5. Slow - how often is that really a problem? Odds are that if it’s too slow in Perl it’s going to be too slow in any language. Or, it was written using a poor algorithm to begin with, which is something that likewise you can do in any language.
  6. Books like PBP help with this problem by telling you what not to do as much as what to do. Brian Kernighan: Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are by definition, not smart enough to debug it.
  7. How good a programmer are/were they? How fluent in Perl?
  8. Too many people skip this step and assume they know what they should do. Are original optimization goals still valid?
  9. Think about testing now. Test with same tools as for Test First. Tests inline make code harder to read though.
  10. Sounds obvious, but if tests aren’t fun to write, haven’t followed. Look for more Test:: modules on CPAN.
  11. Could do same as before - save HTML to file and compare. This is better.
  12. Explain how works.
  13. Pretty to look at means easy on the eyes - not in the usual sense but easy to read. Not formatted with Acme::Eyedropts to look like Mona Lisa. Consistent layout is easy with editors - hit TAB in Emacs.
  14. Common indentation style - none at all.
  15. Not quite my style - braces in K&R style to use fewer lines.
  16. Ok… here it is using my style. So what if it takes up more space. How many people prefer this style, anyway?
  17. You probably want to know which parts of the code are being executed. You might want to know how fast those parts are being executed.
  18. Analysis you do with eyeballs. Example app: 2.5 hrs/1GB -> 20min/12MB, code halved, using hashes. Regexes - except may be optimized for performance. So profile.
  19. If you're working in a team, once you've settled on indentation style you ought to settle commenting style. Here you see the result of paying someone by the line. Note that
  20. this is the only thing here that actually does anything. Dealing with the Documentation Hound is an insidious problem because of course many comments *are* useful and on the whole, people don't use enough of them. It’s like talking to a random group of people and saying, “Y’all need to eat more.” There might be a couple of anorexics in the audience, but for most people, that’s not the right message. But the point is that everything in the program, whether it's code or comments, should contribute towards getting the job done or understanding how it works, and anything that doesn't do that is getting in the way of the stuff that does. So some of these comments would be helpful, but the majority of them are just making it harder for you to read the code.
  21. What can you do about it? Firstly, get rid of the ASCII art. If you want a gap, use a blank line. -click- Next, if the comments relate to how to call public methods or functions, then put them in documentation so anyone can see a proper interface document just by running perldoc. But if you're the kind of project that uses comments about the signature of a function, those are fine. Personally, I leave that information to POD. -click- The whole point of this pruning exercise is to expose the code itself. It was pretty obvious in this example that there was no point at all in having a function for adding one to a number since it would be shorter and clearer just to use ++ in line. Usually, you're not going to be able to inline a subroutine, but if you're taking over maintenance of a coding horror this is the first phase in a rewriting campaign and the next step is line by line editing that may shorten the code still further. Ultimately, you'd like every function and method to be no longer than one screen of your editor. Look at Brian Ingerson. His methods are so short that just the line "my $self = shift" accounted for 10% of their line counts, so he wrote a module to put it in automatically. -click- The comments that you really want are any that answer the question, "Why?" That is the whole point of all documentation: Why is this line of code so weird, why does this function have a bizarre name, why does my database not follow normalization rules, why am I using substr() and index() instead of a simpler regular expression, why, why, why? If you come back to a program you wrote six months ago without perfect documentation, I guarantee that the first question you ask when you look at it again is going to begin with "Why". Anything that answers that question needs to be preserved, enshrined, and embalmed.
  22. I'm not saying you should get rid of all that information about who wrote the program and when, and what changes they made; just that it belongs in the right place. If the program is something you're using in your own environment then you can just use a source code control system. Everything from RCS to Subversion will keep track of all that stuff for you. That's where you'd expect to find that information if you were looking for it, so put it there. If you're making a distribution to send to someone else - such as CPAN - then you can stick that information in a README and a change log file. Okay, moving on to the next example…
  23. Ok, next pop quiz: what does this do? (beat) Beep - time's up.
  24. You just look at that and go, "Oh, of course, it replaces groups of consecutive non-digits with a single space."
  25. Okay, here we have something I copied here verbatim from where I saw it so you could see how the author daringly defied the normal rules of layout for the sake of conciseness, alignment, and general prettiness, and it certainly is pretty. Too bad it's so darned repetitive. Repetitive code is a coding horror that's like a leech sucking on your brain, because part of your brain is going, "okay, skip all these, they're all the same," and another, wiser part of your brain is going, "Wait a minute, I have to check to make sure they *are* all the same." So is this like the regex example - is one of the digits missing? No! But the more cautious among you probably wondered, "Gee, should it include zero in the list? Well, it's a month, and they're usually numbered starting at one, so…" Too much stuff for your brain to think about! You need it for more important things, like how to explain to your wife why you just bought that 50” TV.
  26. So repetitive code is a giant wake-up call that there's a better way of doing something, and of course, here it is. Speaking of repetitive code,
  27. here's another example that's all too common… again, we have someone who's just not impatient enough. Either they like typing, or they like using their editor macros, either way, you've got better things to do than stare at repetitive code making sure all of those things are really the same. Trust me, it's happening, even if you don't realize it - it's the subconscious programmer's brain at work, the same thing that tells you when it's time to eat. Give it something better to do.
  28. This kind of task is exactly why here docs were invented. You just type what you want with the line breaks the way you want them and you don't have to worry about quoting delimiters. "Oh, but Peter, I don't like the text being up against the left margin instead of indented to make it look separate." Well then,
  29. indent it, if that's what you want to do. It's just a regex away. There are umpteen ways of doing this, and if you want to indent the heredoc terminator as well, <click> you can do that too if you quote it right to begin with, or you can use one of a couple of nifty source code filters that do the job for you. The point is, don't be satisfied with repetitive code.
  30. Especially something heinous like this, which always drives me crazy. Folks, when I'm reading a Perl program, I'm in Perl reading mode, and maybe sometimes in regex reading mode. I'm not in HTML reading mode, and I don't want to be. -click- I prefer not to look at the HTML at all, and there are a lot of ways of just get it out into a separate file or files. If you put it in a separate file then you can use an HTML editor on it - no HTML editor is going to be able to validate HTML that’s intertwingled with Perl like this. My favorite HTML editor is - someone else. Because inevitably you get all kinds of requests to make this font two points bigger, or make this background a little bit pinker, and it’s not my kind of thing. But there are people who get off on that, and I’m only too happy to let them edit HTML without having to look at my code. HTML and Perl are like dogs and cats; they just shouldn't breed together. It's bad enough when the HTML is in a heredoc, but when they're mixed together on the same line like this over and over, it's nuts. If you really want to put the HTML in the same file - say because you are the HTML editor and you won’t want anyone else touching your HTML - then use Inline::Files so you can have it in a nice clearly marked separate section where it can't escape and start molesting the Perl code.
  31. Does this look familiar to anyone? It should, because it is pasted verbatim from the perldoc documentation for localtime. You see this all the time, but then inevitably <click> they only usae a couple of the variables. And that part of your brain that acts like a little Perl interpreter is left wondering what those other variables are for and when they’re going to get used.
  32. Just declare the ones you’re going to use.
  33. And if you don’t like the numbers 4 and 3 here,
  34. well you don't even have to do that either, if you don't mind using a module that's come with Perl since at least version 5.004. The anal-retentive part of me is forced to point out that there’s a small bug here in that if in between the first and the second call to localtime the system clock passes midnight at the end of the last day of the month, then the results will be inconsistent. If that should happen to bother you, then by all means use the previous example with the list slice and symbolic constants set to 4 and 3 so you know what they mean. Next…
  35. How many people have seen a program that starts with a laundry list like this? How many of you liked it? This has already filled up the entire screen and we've hardly gotten to any executable code yet. Of course, the Documentation Hound cures this problem by declaring each one on a separate line with its own comment block preceding it saying what it's for, when it first appeared in the program, what values it's allowed to take, and other stuff that makes this ten times longer than it already is. So what do we do about it?
  36. First and most important, variable declarations should go as late as possible. Remember, part of the reader's brain is going to be occupied with remembering every variable for as long as it's in scope, so push them to the innermost scope levels possible. The one exception to that is the variable that's used for specifying some global configuration setting, like the path to an important directory or the value of Avagadro's constant, or something. The main reason for putting those at the top of the code is so that a lesser programmer who comes in wanting to change one of those things in your program will find it quickly and not go spelunking through the rest of your code where they might break something. -click- You can help keep variables in the innermost scope possible by using the fact that 'my' can appear before a variable just about anywhere in Perl and in particular, you can declare a loop variable at the point you say it's a loop variable so that it'll go out of scope as soon as the loop finishes. -click- In fact, you can put 'my' in some pretty unlikely places. The second argument to the getopts() function exported by Getopt::Std is a reference to a hash to store the options specified by the user on the command line. You can even put the 'my' inside an enreferencing backslash there to save on having to declare it in a separate line. -click- This kind of coding horror is usually a symptom of another kind.
  37. It's not really possible to show an example of this on the screen so you'll have to use your imagination. -click- But I'm sure it's familiar to many of you. (How many people know what JCL is?) -click- This is the usual excuse for how the program got that way. -click- And this is the inevitable defense when you point out that you need a machete to hack through the code.
  38. So what do you do? It's not easy. You have to identify areas where variables are used only over a short part of the program, and then see whether that means tghat that part can be taken out into a subroutine. -click- If you use Eclipse - I'm afraid I haven't yet - then you might want to uses the Devel::Refactor module from CPAN, which can figure out what the subroutine for any given chunk of code should be. That doesn't necessarily mean it's going to be a good choice, mind you. -click- Because Monolithic Madness seldom uses strict, that means you're going to have to add it at some point if you want to stay sane. Or become sane, whichever applies to you. You can take a piecemeal approach to this if you want; first, turn on strictness for the whole program, but then embed the rest of the whole program in a naked block and immediately turn strictness off, which of course is going to be a giant no-op. But now you can start pulling code out of that no strictness block at the beginning and the end and fixing the code to be strict compliant as you go, and keep shrinking the size of the inner no strictness block.
  39. I have taken some creative license with the spacing in these examples for the sake of some entertainment value. So this first example is code written by someone whose favorite language is - what?
  40. Yep, C. This just prepends a root path to a bunch of relative paths. Of course, the C programmer is probably wondering at this point how Perl works without a malloc or realloc function.
  41. Here's how a native Perl speaker would do that same task.
  42. This next example is what might come from someone who was more used to… what?
  43. Yep, FORTRAN. This prints a matrix of numbers to a file. I've tried to pick examples here that are sort of in keeping with the kinds of things those languages are generally used for. So a FORTRAN programmer when they want to print something might start looking for something called FORMAT and figure that's what they need to use for printing formatted values. And… yeessss, technically that's correct, but of course that's not how we'd really do that most of the time.
  44. And here's the native Perl solution, or at least one way of doing it.
  45. Okay, this should be a fairly easy one… this is Perl spoken by a what programmer?
  46. That's right. This being a COBOL program, it just adds two numbers together, but because they're numbers representing money, that's okay.
  47. And here's the native Perl solution. It's not really changed much because the original COBOL implies strict fixed-length formatted records, and we use unpack() for handling those in Perl. Of course, we're more used to writing applications that handle less structured input formats, or more modern structured input formats like XML.
  48. Okay, this last example should be pretty easy, you've got the hang of this by now…
  49. Right, BASIC. Okay, so this is the kind of program I used to write when I was learning BASIC: guess what number someone's thinking of, the hard way.
  50. And here's a native Perl solution. The astute reader will note that since the original program never actually *did* anything with the right answer, in this version, it doesn't even stay in scope once we found it. CHANGE TO USE IO::Prompt
  51. Okay, something a little more serious now. I'm going to assume that all of you have seen this code by now, because it's multiplying around the internet like a bad virus. --click- Of course, this is the code to parse CGI inputs - well, the beginning of the code, anyway, I couldn't bring myself to finish pasting it. This is just one instance of it I found somewhere - it wasn't hard, I just stuck out my foot and this tripped over it - and it's better than many I've seen, but still, isn't
  52. *this* a lot easier to read? Not to mention the fact that it's come bundled with the Perl core since 5.004, and it gets the decoding right, unlike the previous code and virtually every other home-grown solution floating out there. It's just a lot harder than most people think to handle all the possibilities. Of course, it doesn't end with CGI.pm. There are still zillions of people parsing XML and HTML with simple regular expressions, people calling out to programs like 'date' and 'cal' instead of using a Date:: module, and people calling database programs like sqlplus instead of using DBI.
  53. Mixed abstraction levels refers to code of different complexity in a method - it should all look the same level of abstraction. Time dependencies means the caller must call methods in a certain order - this pushes some of the responsibilities of the class onto the caller - create methods managing correct calling sequence
  54. Restructuring is easier the less code you have. I recently compressed subroutine from 200 lines to 12. Ideally all blocks fit on screen (mine is 50 lines high). Code that’s not covered, write test for or delete (have got revision control).
  55. Typical. Bug in this line, what is it? Quote missing after $zx4. Another bug. Says $x2 in the values line where the corresponding column name is x3. Tim wouldn’t settle - read DBI, discover placeholders
  56. Still has a bug. $y2 and $y3 are reversed in the argument list. That's not the only bug. There's one too many question marks in the values line.
  57. Maintaining associations between two sets is a hash. Now every time you need to insert values in a table, just call the subroutine.
  58. Nothing ruins reading like text lump. Lots of print statements -> Here document -> separate file (config file) Usually reason for text is creating some web page etc. Candidates for templating, give work to somone else.
  59. People post code using symref unwittingly. Flamed ‘cos couldn't be using strict. strict subs stops calling sub without parens if no def yet, so define sub earlier, or declare stub, or put empty parens after call. strict vars requires lexicals or effort to use package var.
  60. use warnings is relatively new - so probably see -w. And that's fine. use warnings is lexically scoped, so… -W forces warnings everywhere, regardless of attempts to turn off. So use it, decide, remove, use warnings.
  61. Still zillions of people parsing XML and HTML with regexen, calling out to 'date' and 'cal' & sql+. Some code may have been pasted from third-party modules before was okay to trust CPAN.