This document introduces best practices for writing clean and readable Perl code. It provides examples of poorly formatted code and discusses improvements like using strict and warnings, consistent indentation, descriptive variable names, and limiting line length to 80 characters. The examples demonstrate separating code into logical blocks, spacing around operators, and vertical alignment to improve readability. Adopting these styles and standards helps code be more maintainable as projects evolve over time.
My Beginners Perl tutorial, much abbreviated and as presented at the London Perl Workshop on Dec 1st 2007.
Also includes the section on Regular Expressions that we didn't have time for on the day.
Perl 5.10 for People Who Aren't Totally InsaneRicardo Signes
All the hype about perl 5.10 can sound a little intimidating. User-level pragmata! Overloadable smartmatching operator! Thread-safe refkey hashes! For Pete's sake, have you heard about lexically scoped pluggable regexp engines?
It's enough to make you think that 5.10's changes are just for the hard-core perl hackers, but it couldn't be further from the truth! The new version of Perl is full of changes that are easy to use and pack lots of useful benefits for doing plain old every day Perl programming.
We'll look at the new features, small and large, and see why you, too, will love 5.10.
Perl, a cross-platform, open-source computer programming language used widely in the commercial and private computing sectors. Perl is a favourite among Web developers for its flexible, continually evolving text-processing and problem-solving capabilities.
My Beginners Perl tutorial, much abbreviated and as presented at the London Perl Workshop on Dec 1st 2007.
Also includes the section on Regular Expressions that we didn't have time for on the day.
Perl 5.10 for People Who Aren't Totally InsaneRicardo Signes
All the hype about perl 5.10 can sound a little intimidating. User-level pragmata! Overloadable smartmatching operator! Thread-safe refkey hashes! For Pete's sake, have you heard about lexically scoped pluggable regexp engines?
It's enough to make you think that 5.10's changes are just for the hard-core perl hackers, but it couldn't be further from the truth! The new version of Perl is full of changes that are easy to use and pack lots of useful benefits for doing plain old every day Perl programming.
We'll look at the new features, small and large, and see why you, too, will love 5.10.
Perl, a cross-platform, open-source computer programming language used widely in the commercial and private computing sectors. Perl is a favourite among Web developers for its flexible, continually evolving text-processing and problem-solving capabilities.
If your not using an ORM (object relational mapper) and are still writing SQL by hand, here's what you need to know.
An introduction into DBIx::Class and some of the concepts and goodies you should be aware off.
These are the slides I was using when delivering a short talk in Vienna PHP. The talk took place in Vienna on September 22th. More information about the PHP course I deliver can be found at php.course.lifemichael.com
This is the ninth set of slightly updated slides from a Perl programming course that I held some years ago.
I want to share it with everyone looking for intransitive Perl-knowledge.
A table of content for all presentations can be found at i-can.eu.
The source code for the examples and the presentations in ODP format are on https://github.com/kberov/PerlProgrammingCourse
Obfuscation, Golfing and Secret Operators in PerlJosé Castro
Everything you always wanted to know about Obfuscation and Golfing, some strange techniques and odd operators many are not aware of.
Also, everything you *never* wished to know about Obfuscation and Golfing, some even stranger techniques and even odder operators many wished they were *not* aware of.
Video available at http://conferences.yapcasia.org/ya2008/talk/1007.
If your not using an ORM (object relational mapper) and are still writing SQL by hand, here's what you need to know.
An introduction into DBIx::Class and some of the concepts and goodies you should be aware off.
These are the slides I was using when delivering a short talk in Vienna PHP. The talk took place in Vienna on September 22th. More information about the PHP course I deliver can be found at php.course.lifemichael.com
This is the ninth set of slightly updated slides from a Perl programming course that I held some years ago.
I want to share it with everyone looking for intransitive Perl-knowledge.
A table of content for all presentations can be found at i-can.eu.
The source code for the examples and the presentations in ODP format are on https://github.com/kberov/PerlProgrammingCourse
Obfuscation, Golfing and Secret Operators in PerlJosé Castro
Everything you always wanted to know about Obfuscation and Golfing, some strange techniques and odd operators many are not aware of.
Also, everything you *never* wished to know about Obfuscation and Golfing, some even stranger techniques and even odder operators many wished they were *not* aware of.
Video available at http://conferences.yapcasia.org/ya2008/talk/1007.
EcoPlanet Bamboo wins 1st place in the popular voting category and becomes a top 5 finalist globally for best for-profit enterprises with a positive impact on tropical forests. EcoPlanet Bamboo is also the first bamboo company ever to receive VSC carbon certification and FSC certification for tropical clumping bamboo.
Aquí pots trobar els productes dels pagesos que cuiden el medi ambient a Menorca i que han signat un acord de Custòdia del Territori amb el GOB. Més informació a www.gobmenorca.com/agrobotiga
There are four constraints for internet of things to succeed: devices should have connectivity even on a long range, connectivity should be free and secure, devices consume very little power and the form factor is reduced to the size of the battery. LoRa enables this: long range, low power communication over free-to-use frequencies around the world. In this talk, I will introduce the open standard LoRaWAN: the wide area network protocol stack built on top of LoRa, maintained by telecom operators, chipmakers and IoT industry leaders.
With a $ 1,200 gateway in our hands, we imagined covering the city of Amsterdam with only ten gateways. Four weeks later, we crowd sourced the gateways and launched the first open LoRa covered city network in the world. The open source, open hardware initiative, The Things Network, spread like wildfire around the world. After a very successful Kickstarter campaign to enable producing affordable gateways, development kits and nodes, we started building the network with the community. LoRaWAN is at the core of this network, and in this talk I'll explain its role in our mission to build an open, decentralized and crowd sourced internet of things data network with global coverage.
The 7 strategies I use when writing listicles and list posts for the Buffer blog.
1. Use an odd number
2. Use a prime number
3. Create mega lists
4. Listicle inception
5. Start with more than you need
6. Number your lists
7. Write words, too
The full article and sources are here: http://bit.ly/kevanlist
2nd screen monetization driven by enagegment by Roope Suomalainen, OTTtv Worl...Ixonos Plc
During the Next-Generation Advertising Day at the OTTtv World Summit, which took place in London on 17-20 November 2014, Roope Suomalainen head of media at Ixonos, delivered a presentation titled “2nd Screen Monetization Driven by Engagement". As the leading event in the over-the-top TV market, this was a perfect forum to address the lack of innovation in advertising that plagues the digital era. It is time to put an end to the narrow-minded TV-led view to advertising and see where the real monetisation opportunities lie today.
Dealing with Legacy Perl Code - Peter ScottO'Reilly Media
Peter Scott, author of the O'Reilly School of Technology's Perl Programming Certificate series, talks about how to deal with "legacy" Perl code - written by someone else, or maybe even yourself when you were younger and less wise.
Writing Modular Command-line Apps with App::CmdRicardo Signes
It's easy to write command-line programs in Perl. There are a million option parsers to choose from, and Perl makes it easy to deal with input, output, and all that stuff.
Once your program has gotten beyond just taking a few switches, though, it can be difficult to maintain a clear interface and well-tested code. App::Cmd is a lightweight framework for writing easy to manage CLI programs.
This talk provides an introduction to writing programs with App::Cmd.
Climbing the Abstract Syntax Tree (IPC Fall 2017)James Titcumb
The new Abstract Syntax Tree (AST) in PHP 7 means the way our PHP code is being executed has changed. Understanding this new fundamental compilation step is key to understanding how our code is being run.
To demonstrate, James will show how a basic compiler works and how introducing an AST simplifies this process. We’ll look into how these magical time-warp techniques* can also be used in your code to introspect, analyse and modify code in a way that was never possible before.
After seeing this talk, you’ll have a great insight as to the wonders of an AST, and how it can be applied to both compilers and userland code.
(*actual magic or time-warp not guaranteed)
Some techniques from the heady world of Functional Programming implemented in idiomatic Perl using various techniques: closures, iterators, Devel::Declare, and some distilled evil. New version now with monads! (As presented at http://conferences.yapceurope.org/lpw2008/ )
Climbing the Abstract Syntax Tree (PHP South Africa 2017)James Titcumb
The new Abstract Syntax Tree (AST) in PHP 7 means the way our PHP code is being executed has changed. Understanding this new fundamental compilation step is key to understanding how our code is being run. To demonstrate, James will show how a basic compiler works and how introducing an AST simplifies this process. We’ll look into how these magical time-warp techniques* can also be used in your code to introspect, analyse and modify code in a way that was never possible before. After seeing this talk, you'll have a great insight as to the wonders of an AST, and how it can be applied to both compilers and userland code. (*actual magic or time-warp not guaranteed)
Climbing the Abstract Syntax Tree (PHP Developer Days Dresden 2018)James Titcumb
The new Abstract Syntax Tree (AST) in PHP 7 means the way our PHP code is being executed has changed. Understanding this new fundamental compilation step is key to understanding how our code is being run.
To demonstrate, James will show how a basic compiler works and how introducing an AST simplifies this process. We’ll look into how these magical time-warp techniques* can also be used in your code to introspect, analyse and modify code in a way that was never possible before.
After seeing this talk, you’ll have a great insight as to the wonders of an AST, and how it can be applied to both compilers and userland code.
(*actual magic or time-warp not guaranteed)
Climbing the Abstract Syntax Tree (CodeiD PHP Odessa 2017)James Titcumb
The new Abstract Syntax Tree (AST) in PHP 7 means the way our PHP code is being executed has changed. Understanding this new fundamental compilation step is key to understanding how our code is being run.
To demonstrate, James will show how a basic compiler works and how introducing an AST simplifies this process. We’ll look into how these magical time-warp techniques* can also be used in your code to introspect, analyse and modify code in a way that was never possible before.
After seeing this talk, you’ll have a great insight as to the wonders of an AST, and how it can be applied to both compilers and userland code.
(*actual magic or time-warp not guaranteed)
One criticism of opponents of Perl is that it is a "write-only" language meaning that once the code is written, it is extremely difficult to maintain because it is difficult to understand upon re-examination. As with many criticisms, this should be aimed at those undisciplined developers who are writing the code, and not their tool of choice.
Having said that, I think it is also fair to say that Perl makes it very easy to write difficult-to-decipher code. This is the doubleedged sword which is the shorthand Perl gives us to be very expressive in a small amount of space. A negative application of this is obfuscated Perl (where the author intentionally makes his code difficult to read), while a more positive application is the craft of creating Perl "oneliners" (trying to include a great deal of functionality in a single line of code). A oneliner can be a powerful weapon in the arsenal of a system administrator.
In this talk:
* We'll look at a line of code in a subroutine that is in desperate need of readability changes
* We'll make the code more readable by introducing:
* appropriate whitespace
* different ways of writing the same thing, for example: $array[$#array] vs. $array[-1]
* useful names for variables, versus $index, $j $k $l, etc
* breaking up one line of code into multiple lines
* exploring further improvements through Perl::Critic and by extension Perl::Tidy
This talk will be beginner-friendly.
Climbing the Abstract Syntax Tree (DPC 2017)James Titcumb
The new Abstract Syntax Tree (AST) in PHP 7 means the way our PHP code is being executed has changed. Understanding this new fundamental compilation step is key to understanding how our code is being run.
To demonstrate, James will show how a basic compiler works and how introducing an AST simplifies this process. We’ll look into how these magical time-warp techniques* can also be used in your code to introspect, analyse and modify code in a way that was never possible before.
After seeing this talk, you'll have a great insight as to the wonders of an AST, and how it can be applied to both compilers and userland code.
(*actual magic or time-warp not guaranteed)
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
6. What is SAPO?
• Older than Google,
kind of like Yahoo!
• 100+ techs
7. What is SAPO?
• Older than Google,
kind of like Yahoo!
• 100+ techs
• 100+ non-techs
8. What is SAPO?
• Older than Google,
kind of like Yahoo!
• 100+ techs
• 100+ non-techs
• Mail, Blogs, Photos,Videos, Links, Cars, Real
Estate, Jobs, Maps, Encyclopedia online,
Search, Messaging, Social Network, etc., etc.,
etc.
10. What do I do at SAPO?
• Evangelism (motivation, productivity, quality)
11. What do I do at SAPO?
• Evangelism (motivation, productivity, quality)
• Organize the training program
12. What do I do at SAPO?
• Evangelism (motivation, productivity, quality)
• Organize the training program
• Recruitment (lots of interviews every week)
13. What do I do at SAPO?
• Evangelism (motivation, productivity, quality)
• Organize the training program
• Recruitment (lots of interviews every week)
• Organize events
14. What do I do at SAPO?
• Evangelism (motivation, productivity, quality)
• Organize the training program
• Recruitment (lots of interviews every week)
• Organize events
• Etc.
18. “Why?”
• tomorrow, you may need to fix a glitch in
your code
• next week, you may need to confirm
something
• 6 months from now, you may need to
develop a new feature
21. use strict;
my @list=('Emacs', 'Vi '); my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i=int ($rand+rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
22. use strict;
my @list=('Emacs', 'Vi '); my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i=int ($rand+rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
23. use strict;
my @list=('Emacs', 'Vi '); my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i=int ($rand+rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
24. use strict;
my @list=('Emacs', 'Vi '); my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i=int ($rand+rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
25. use strict;
my @list=('Emacs', 'Vi '); my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i=int ($rand+rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
26. use strict;
my @list=('Emacs', 'Vi '); my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i=int ($rand+rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
27. use strict;
my @list=('Emacs', 'Vi '); my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i=int ($rand+rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
28. use strict;
my @list=('Emacs', 'Vi '); my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i=int ($rand+rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
29. Block separation
• A program is a list of instructions
• You’re writing it as a letter
• Separate your paragraphs, for clarity
30. use strict;
my @list=('Emacs', 'Vi '); my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i=int ($rand+rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
31. use strict;
my @list=('Emacs', 'Vi '); my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i=int ($rand+rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
33. use strict;
my @list=('Emacs', 'Vi '); my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i=int ($rand+rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
34. use strict;
my @list=('Emacs', 'Vi ');
my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i=int ($rand+rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
36. use strict;
my @list=('Emacs', 'Vi ');
my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i=int ($rand+rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
37. use strict;
my @list=('Emacs', 'Vi ');
my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i=int ($rand+rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
38. Spaces around
operators
• Don’t clutter things up
• Spaces around operators help you find
them more easily
39. use strict;
my @list=('Emacs', 'Vi ');
my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i=int ($rand+rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
40. use strict;
my @list=('Emacs', 'Vi ');
my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i=int ($rand+rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
41. use strict;
my @list = ('Emacs', 'Vi ');
my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i = int ($rand + rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
42. Naming variables
• Don’t name them “var”, “list”, “hash” or
anything else that does not have a meaning
• Make sure the name helps you identify
what it is
43. use strict;
my @list = ('Emacs', 'Vi ');
my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i = int ($rand + rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
44. use strict;
my @editors = ('Emacs', 'Vi ');
my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i = int ($rand + rand());
print " $editors[$i] users are from Venus" . ",
"$editors[1-$i] users are from Mars" .
"n";
}
46. use strict;
my @editors = ('Emacs', 'Vi ');
my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i = int ($rand + rand());
print " $editors[$i] users are from Venus" . ",
"$editors[1-$i] users are from Mars" .
"n";
}
47. use strict;
my @editors = ('Emacs', 'Vi ');
my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i = int ($rand + rand());
print " $editors[$i] users are from Venus" . ",
"$editors[1-$i] users are from Mars" .
"n";
}
49. my @list = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47
my @list2 = (1,1,2,3,5,8,13,21,34,55,89,144,233,377,
for my $number (@list) {
if (grep{$number==$_}@list2) {print "$number is
}
50. my @list = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47
my @list2 = (1,1,2,3,5,8,13,21,34,55,89,144,233,377,
for my $number (@list) {
if (grep{$number==$_}@list2) {print "$number is
}
51. my @list = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47
my @list2 = (1,1,2,3,5,8,13,21,34,55,89,144,233,377,
for my $number (@list) {
if (grep{$number==$_}@list2) {print "$number is
}
52. my @list = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47
my @list2 = (1,1,2,3,5,8,13,21,34,55,89,144,233,377,
for my $number (@list) {
if (grep{$number==$_}@list2) {print "$number is
}
53. my @list = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47
my @list2 = (1,1,2,3,5,8,13,21,34,55,89,144,233,377,
for my $number (@list) {
if (grep{$number==$_}@list2) {print "$number is
}
54. 2 is both a prime number and a fibonacci number
3 is both a prime number and a fibonacci number
5 is both a prime number and a fibonacci number
13 is both a prime number and a fibonacci number
89 is both a prime number and a fibonacci number
55. Strict and warnings
• both strict and warnings will help you avoid
lots of pesky mistakes
56. my @list = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47
my @list2 = (1,1,2,3,5,8,13,21,34,55,89,144,233,377,
for my $number (@list) {
if (grep{$number==$_}@list2) {print "$number is
}
57. use strict;
use warnings;
my @list = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47
my @list2 = (1,1,2,3,5,8,13,21,34,55,89,144,233,377,
for my $number (@list) {
if (grep{$number==$_}@list2) {print "$number is
}
58. Avoid lines over 80 charac
• code is easier to read if it fits on the screen
• even if using line wrapping, having to figure
out if two lines are different instructions or
the same one is harder than not having to
do it
59. use strict;
use warnings;
my @list = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47
my @list2 = (1,1,2,3,5,8,13,21,34,55,89,144,233,377,
for my $number (@list) {
if (grep{$number==$_}@list2) {print "$number is
}
60. use strict;
use warnings;
my @list = (2,3,5,7,11,13,17,19,23,29,31,
37,41,43,47,53,59,61,67,71,73,79,83,89,97,101) ;
my @list2 = (1,1,2,3,5,8,13,21,34,55,89,
144,233,377,610,987,1597,2584,4181,6765) ;
for my $number (@list) {
if (grep{$number==$_}@list2) {
print "$number is both a prime number and a
}
61. use strict;
use warnings;
my @list = (2,3,5,7,11,13,17,19,23,29,31,
37,41,43,47,53,59,61,67,71,73,79,83,89,97,101) ;
my @list2 = (1,1,2,3,5,8,13,21,34,55,89,
144,233,377,610,987,1597,2584,4181,6765) ;
for my $number (@list) {
if (grep{$number==$_}@list2) {
print "$number is both a prime number " . " a
}
62. use strict;
use warnings;
my @list = (2,3,5,7,11,13,17,19,23,29,31,
37,41,43,47,53,59,61,67,71,73,79,83,89,97,101) ;
my @list2 = (1,1,2,3,5,8,13,21,34,55,89,
144,233,377,610,987,1597,2584,4181,6765) ;
for my $number (@list) {
if (grep{$number==$_}@list2) {
print "$number is both a prime number " .
" and a fibonacci numbern"}
}
63. When breaking lines,
align vertically
• a broken line is a visual accident waiting to
happen
64. use strict;
use warnings;
my @list = (2,3,5,7,11,13,17,19,23,29,31,
37,41,43,47,53,59,61,67,71,73,79,83,89,97,101) ;
my @list2 = (1,1,2,3,5,8,13,21,34,55,89,
144,233,377,610,987,1597,2584,4181,6765) ;
for my $number (@list) {
if (grep{$number==$_}@list2) {
print "$number is both a prime number " .
" and a fibonacci numbern"}
}
65. use strict;
use warnings;
my @list = (2,3,5,7,11,13,17,19,23,29,31,
37,41,43,47,53,59,61,67,71,73,79,83,89,9
my @list2 = (1,1,2,3,5,8,13,21,34,55,89,
144,233,377,610,987,1597,2584,4181,6765
for my $number (@list) {
if (grep{$number==$_}@list2) {
print "$number is both a prime number " .
" and a fibonacci numbern"}
}
66. Add spaces after a
comma
• spaces after a comma help you visually
separate items
67. use strict;
use warnings;
my @list = (2,3,5,7,11,13,17,19,23,29,31,
37,41,43,47,53,59,61,67,71,73,79,83,89,9
my @list2 = (1,1,2,3,5,8,13,21,34,55,89,
144,233,377,610,987,1597,2584,4181,6765
for my $number (@list) {
if (grep{$number==$_}@list2) {
print "$number is both a prime number " .
" and a fibonacci numbern"}
}
68. use strict;
use warnings;
my @list = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31,
37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
my @list2 = (1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,
144, 233, 377, 610, 987, 1597, 2584, 41
for my $number (@list) {
if (grep{$number==$_}@list2) {
print "$number is both a prime number " .
" and a fibonacci numbern"}
}
69. Organize long lists
as tables
• the brain identifies patterns such as tables
much more easily
70. use strict;
use warnings;
my @list = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31,
37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
my @list2 = (1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,
144, 233, 377, 610, 987, 1597, 2584, 41
for my $number (@list) {
if (grep{$number==$_}@list2) {
print "$number is both a prime number " .
" and a fibonacci numbern"}
}
71. use strict;
use warnings;
my @list = ( 2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
my @list2 = (1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,
144, 233, 377, 610, 987, 1597, 2584, 41
for my $number (@list) {
if (grep{$number==$_}@list2) {
print "$number is both a prime number " .
" and a fibonacci numbern"}
}
72. use strict;
use warnings;
my @list = ( 2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
my @list2 = ( 1, 1, 2, 3, 5, 8, 13, 2
144, 233, 377, 610, 987, 1597, 2584, 41
for my $number (@list) {
if (grep{$number==$_}@list2) {
print "$number is both a prime number " .
" and a fibonacci numbern"}
}
73. Again, name variables
appropriately
• the brain identifies patterns such as tables
much more easily
74. use strict;
use warnings;
my @list = ( 2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
my @list2 = ( 1, 1, 2, 3, 5, 8, 13, 2
144, 233, 377, 610, 987, 1597, 2584, 41
for my $number (@list) {
if (grep{$number==$_}@list2) {
print "$number is both a prime number " .
" and a fibonacci numbern"}
}
75. use strict;
use warnings;
my @prime_numbers = ( 2, 3, 5, 7, 11, 13, 17, 19,
37, 41, 43, 47, 53, 59, 61, 67,
my @fibonnaci = ( 1, 1, 2, 3, 5, 8,
144, 233, 377, 610, 987, 1597,
for my $number (@prime_numbers) {
if (grep{$number==$_}@fibonnaci) {
print "$number is both a prime number " .
" and a fibonacci numbern"}
}
76. Spaces for clarity
• around operators
• around blocks
• around anything else that may cause
confusion
77. use strict;
use warnings;
my @prime_numbers = ( 2, 3, 5, 7, 11, 13, 17, 19,
37, 41, 43, 47, 53, 59, 61, 67,
my @fibonnaci = ( 1, 1, 2, 3, 5, 8,
144, 233, 377, 610, 987, 1597,
for my $number (@prime_numbers) {
if (grep{$number==$_}@fibonnaci) {
print "$number is both a prime number " .
" and a fibonacci numbern"}
}
78. use strict;
use warnings;
my @prime_numbers = ( 2, 3, 5, 7, 11, 13, 17, 19,
37, 41, 43, 47, 53, 59, 61, 67,
my @fibonnaci = ( 1, 1, 2, 3, 5, 8,
144, 233, 377, 610, 987, 1597,
for my $number (@prime_numbers) {
if ( grep { $number == $_ } @fibonnaci ) {
print "$number is both a prime number " .
" and a fibonacci numbern"}
}
79. Block closing
• the closing curly brace should be in a line
by itself
• this helps better identify where the block
ends
80. use strict;
use warnings;
my @prime_numbers = ( 2, 3, 5, 7, 11, 13, 17, 19,
37, 41, 43, 47, 53, 59, 61, 67,
my @fibonnaci = ( 1, 1, 2, 3, 5, 8,
144, 233, 377, 610, 987, 1597,
for my $number (@prime_numbers) {
if ( grep { $number == $_ } @fibonnaci ) {
print "$number is both a prime number " .
" and a fibonacci numbern"}
}
81. use strict;
use warnings;
my @prime_numbers = ( 2, 3, 5, 7, 11, 13, 17, 19,
37, 41, 43, 47, 53, 59, 61, 67,
my @fibonnaci = ( 1, 1, 2, 3, 5, 8,
144, 233, 377, 610, 987, 1597,
for my $number (@prime_numbers) {
if ( grep { $number == $_ } @fibonnaci ) {
print "$number is both a prime number " .
" and a fibonacci numbern"
}
}
82. Always end a statement
with a semicolon
• even if it’s the last statement in the block
• even if the closing curly brace is on the
same line
• this will allow you to add another
statement without having to check the line
above
83. use strict;
use warnings;
my @prime_numbers = ( 2, 3, 5, 7, 11, 13, 17, 19,
37, 41, 43, 47, 53, 59, 61, 67,
my @fibonnaci = ( 1, 1, 2, 3, 5, 8,
144, 233, 377, 610, 987, 1597,
for my $number (@prime_numbers) {
if ( grep { $number == $_ } @fibonnaci ) {
print "$number is both a prime number " .
" and a fibonacci numbern"
}
}
84. use strict;
use warnings;
my @prime_numbers = ( 2, 3, 5, 7, 11, 13, 17, 19,
37, 41, 43, 47, 53, 59, 61, 67,
my @fibonnaci = ( 1, 1, 2, 3, 5, 8,
144, 233, 377, 610, 987, 1597,
for my $number (@prime_numbers) {
if ( grep { $number == $_ } @fibonnaci ) {
print "$number is both a prime number " .
" and a fibonacci numbern";
}
}
85. Inside a loop, use empty
lines around the body
• this is also going to help you identify the
beginning and the end of the loop
86. use strict;
use warnings;
my @prime_numbers = ( 2, 3, 5, 7, 11, 13, 17, 19,
37, 41, 43, 47, 53, 59, 61, 67,
my @fibonnaci = ( 1, 1, 2, 3, 5, 8,
144, 233, 377, 610, 987, 1597,
for my $number (@prime_numbers) {
if ( grep { $number == $_ } @fibonnaci ) {
print "$number is both a prime number " .
" and a fibonacci numbern";
}
}
87. use strict;
use warnings;
my @prime_numbers = ( 2, 3, 5, 7, 11, 13, 17, 19,
37, 41, 43, 47, 53, 59, 61, 67,
my @fibonnaci = ( 1, 1, 2, 3, 5, 8,
144, 233, 377, 610, 987, 1597,
for my $number (@prime_numbers) {
if ( grep { $number == $_ } @fibonnaci ) {
print "$number is both a prime number " .
" and a fibonacci numbern";
}
}
89. for my $number (@prime_numbers) {
if ( grep { $number == $_ } @fibonnaci ) {
print "$number is both a prime number " .
" and a fibonacci numbern";
}
}
104. use List::MoreUtils qw(any);
if ( is_fibonnaci($number) ) {
sub is_fibonnaci {
my $number = shift;
return any { $number == $_ } @fibonnaci
}
105. for my $number (@prime_numbers) {
if ( grep { $number == $_ } @fibonnaci ) {
print "$number is both a prime number " .
" and a fibonacci numbern";
}
}
106. for my $number (@prime_numbers) {
if ( is_fibonnaci($number) ) {
print "$number is both a prime number " .
" and a fibonacci numbern";
}
}
107. for my $number (@prime_numbers) {
if ( is_fibonnaci($number) ) {
print "$number is both a prime number " .
" and a fibonacci numbern";
}
}
sub is_fibonnaci {
my $number = shift;
return any { $number == $_ } @fibonnaci;
108. for my $number (@prime_numbers) {
if ( is_fibonnaci($number) ) {
print "$number is both a prime number " .
" and a fibonacci numbern";
}
}
109. for (@prime_numbers) {
if ( is_fibonnaci($_) ) {
print "$_ is both a prime number " .
" and a fibonacci numbern";
}
}
127. • Perl::Tidy - “Parses and beautifies perl
source”
• Perl::Critic - “Critique Perl source code for
best-practices”
128. Perl::Tidy
use strict;
my @list=('Emacs', 'Vi '); my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i=int ($rand+rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
129. Perl::Tidy
use strict;
my @list = ( 'Emacs', 'Vi ' );
my $rand = rand();
print "10 random users said:n";
foreach ( 0 .. 10 ) {
my $i = int( $rand + rand() );
print " $list[$i] users are from Venus" . ", "
. "$list[1-$i] users are from Mars" . "n";
}
131. Perl::Critic
use strict;
my @list=('Emacs', 'Vi '); my $rand = rand();
print "10 random users said:n";
foreach(0..10) {
my $i=int ($rand+rand());
print " $list[$i] users are from Venus" . ", " .
"$list[1-$i] users are from Mars" .
"n";
}
133. Perl::Critic
• configurable (several severity levels,
extendable, .perlcriticrc)
• integrates with most text editors
• some people also use it as an svn hook
• if you don’t own PBP, there’s also user-
contributed documentation on each subject