This document provides a 3-sentence summary of a Perl programming course document on syntax:
The document covers Perl programming syntax including declarations, statements, comments, operators, loops, and conditionals. Sections include declarations of variables and subroutines, simple and compound statements, comments and documentation, conditional statements, loops and loop control, logical and mathematical operators, and operator precedence. The goal of the course is to teach the essential Perl syntax for writing Perl programs.
This is the seventh 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
Full-day tutorial for the dutch php conference 2011 giving a very quick tour around all the various areas of the ZCE syllabus and some tips on the exam styles
This is the second 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
This is the third 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
This is the seventh 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
Full-day tutorial for the dutch php conference 2011 giving a very quick tour around all the various areas of the ZCE syllabus and some tips on the exam styles
This is the second 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
This is the third 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
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
PHP 8.0 comes with many long-awaited features: A just-in-time compiler, attributes, union types, and named arguments are just a small part of the list. As a major version, it also includes some backward-incompatible changes, which are centered around stricter error handling and enhanced type safety. Let's have an overview of the important changes in PHP 8.0 and how they might affect you!
PHP 8.1 brings Enums, one of the most requested features in PHP.
Enums, or Enumerations, allow creating strict and type-safe structures for fixed values. An Enum structure can hold a number of values that can also be backed with integer or string values.
In this comprehensive session, we will discover what Enums are, why they are useful, how to apply them on our applications, and things to watch out for when using Enums.
From ReactPHP to Facebook Hack's Async implementation and many more, asynchronous programming has been a 'hot' topic lately. But how well does async programming support work in PHP and what can you actually use it for in your projects ? Let's look at some real-world use cases and how they leverage the power of async to do things you didn't know PHP could do.
Vibrant Technologies is headquarted in Mumbai,India.We are the best Perl Scripting training provider in Navi Mumbai who provides Live Projects to students.We provide Corporate Training also.We are Best Perl Scripting classes in Mumbai according to our students and corporators
Tissue culture and virus indexing for the production of clean planting materialsILRI
Poster prepared by P. Asami, C. Too, M. Macharia, P. Niyonzima, D. Bigirimanaa, G. Ndarubayemwo, D. Beyene, J. Harvey and T.A. Holton for the ILRI APM 2013, Addis Ababa, 15-17 May 2013
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
PHP 8.0 comes with many long-awaited features: A just-in-time compiler, attributes, union types, and named arguments are just a small part of the list. As a major version, it also includes some backward-incompatible changes, which are centered around stricter error handling and enhanced type safety. Let's have an overview of the important changes in PHP 8.0 and how they might affect you!
PHP 8.1 brings Enums, one of the most requested features in PHP.
Enums, or Enumerations, allow creating strict and type-safe structures for fixed values. An Enum structure can hold a number of values that can also be backed with integer or string values.
In this comprehensive session, we will discover what Enums are, why they are useful, how to apply them on our applications, and things to watch out for when using Enums.
From ReactPHP to Facebook Hack's Async implementation and many more, asynchronous programming has been a 'hot' topic lately. But how well does async programming support work in PHP and what can you actually use it for in your projects ? Let's look at some real-world use cases and how they leverage the power of async to do things you didn't know PHP could do.
Vibrant Technologies is headquarted in Mumbai,India.We are the best Perl Scripting training provider in Navi Mumbai who provides Live Projects to students.We provide Corporate Training also.We are Best Perl Scripting classes in Mumbai according to our students and corporators
Tissue culture and virus indexing for the production of clean planting materialsILRI
Poster prepared by P. Asami, C. Too, M. Macharia, P. Niyonzima, D. Bigirimanaa, G. Ndarubayemwo, D. Beyene, J. Harvey and T.A. Holton for the ILRI APM 2013, Addis Ababa, 15-17 May 2013
Managers are the biggest occupational group in the UK – and
over 800,000 new jobs will be created in management between
2010 and 2017. However, only one in five managers in the UK is
professionally qualified.
Delayed recovery from anaesthesia by prof. minnu m. panditraoMinnu Panditrao
Prof. Minnu M. Panditrao analyses the very common and potentially dangerous problem/s of the Delayed post-ooperative/ anaesthetic recovery and how to overcome the problem
Strategic Management: Organizational DesignTriune Global
There are a number of factors that differentiate small-business operations from large-business operations, one of which is the implementation of a formal organizational structure. Organizational structure is important for any growing company to provide guidance and clarity on specific human resources issues, such as managerial authority. Small-business owners should begin thinking about a formal structure early in the growth stage of their business.
AMC Squarelearning Bangalore is the best training institute for a career development. it had students from various parts of the country and even few were from West African countries.
This presentation is for those students and IT professionals who have basic programming knowledge and want to learn Perl basics for Pentesting.
We have explained minimal Perl basics which a pentester should know to write,read,modify Perl scripts for Pentesting like data type, comparison operator, loop controls, minimal CPAN modules related to web and networking, perl scripts in Kali and some demo
Това е превод на български от Теодора Берова на четвъртия урок от поредицата уроци, които водих преди време за QA-отдела на голяма международна компания, по покана на Светлин Наков.
Искам да го споделя с всеки, който търси непреходни знания по Perl.
Таблица със съдържанието на курса може да бъде намерена на http://i-can.eu/ .
Изходният код на примерите и уроците в ODP формат се намират на адрес https://github.com/kberov/PerlProgrammingCourse/ .
Това е превод на български от Теодора Берова на третия урок от поредицата уроци, които водих преди време за QA-отдела на голяма международна компания, по покана на Светлин Наков.
Искам да го споделя с всеки, който търси непреходни знания по Perl.
Обновяванията след 1ви юни 2014 и преводът са направени с подкрепата на Chain Solutions (http://chainsolutions.net/).
Таблица със съдържанието на курса може да бъде намерена на http://i-can.eu/ .
Изходният код на примерите и уроците в ODP формат се намират на адрес https://github.com/kberov/PerlProgrammingCourse/ .
Това е превод на български от Теодора Берова на втория урок от поредицата уроци, които водих преди време за QA-отдела на голяма международна компания, по покана на Светлин Наков.
Искам да го споделя с всеки, който търси непреходни знания по Perl.
Обновяванията след 1ви юни 2014 и преводът са направени с подкрепата на Chain Solutions (http://chainsolutions.net/).
Таблица със съдържанието на курса може да бъде намерена на http://i-can.eu/ .
Изходният код на примерите и уроците в ODP формат се намират на адрес https://github.com/kberov/PerlProgrammingCourse/ .
Това е превод на български от Теодора Берова на първият урок от поредицата уроци, които водих преди време за QA-отдела на голяма международна компания, по покана на Светлин Наков.
Искам да го споделя с всеки, който търси непреходни знания за Perl.
Обновяванията след 1ви юни 2014 и преводът са направени с подкрепата на Chain Solutions (http://chainsolutions.net/).
Таблица със съдържанието на курса може да бъде намерена на http://i-can.eu/ .
Изходният код на примерите и уроците в ODP формат се намират на адрес https://github.com/kberov/PerlProgrammingCourse/ .
This is the fourteenth (and last for now) set of 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
This is the thirteenth set of 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
This is the twelfth 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
This is the eleventh 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
This is the sixth 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
This is the fourth 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
This is the first set of slightly updated slides from a Perl programming course that I held some years ago for the QA team of a big international company.
I want to share it with everyone looking for intransitive Perl-knowledge.
The updates after 1st of June 2014 are made with the kind support of Chain Solutions (http://chainsolutions.net/)
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
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
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.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
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/
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.
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.
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
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
2. Contents
1. Declarations
2. Simple Statements
3. Compound Statements
4. Comments and POD
5. Conditional Statements
(Statement Modifiers)
6. Loops and loop control
7. Logical operators
8. Mathematical operators
9. Operator Precedence and Associativity
10.Error handling
3. Declarations
• my - declare and assign a local variable
(lexical scoping)
• our - declare and assign a package
variable (lexical scoping)
• local - create a temporary value for a
global variable (dynamic scoping)
• sub - declare a subroutine, possibly
anonymously
4. Declarations
• Example:
use strict; use warnings;
our $dog = 'Puffy';
{
local $ =$/;
print 'A line-feed is appended.';
}
tell_dogs();
print 'No new line at the end. ';
print 'A line feed is appended.'.$/; #;)
sub tell_dogs {
local $ =$/;
print 'Our dog is named ' . $dog;
my $dog = 'Betty';
print 'My dog is named ' . $dog;
}
5. Simple Statements
• The only kind of simple statement is an
expression evaluated for its side effects.
• Every simple statement must be terminated
with a semicolon(;).
• If it is the final statement in a block, the
semicolon is optional.
• eval{} and do{} look like compound
statements, but aren't
• eval{} and do{} need an explicit termination
6. Simple Statements
• Example:
use strict;
use warnings;
$ = $/;
my $simple = 'A simple statement.';
print $simple;
eval { print $simple };
do { print $simple };
do {
$_++;
print $simple ,' ',$_,'+2'
};
7. Compound Statements
• A compound statement usually contains:
• labels
• conditional constructions and blocks
• several simple statements enclosed in
a block
• the block defines a scope
8. Compound Statements
(2)
• A BLOCK is delimited by curly brackets – {}
• The braces are required
• Perl offers several ways to write conditionals
without curly brackets.
• The continue BLOCK is always executed just
before the conditional is about to be evaluated
again.
• A LABEL gives its associated control flow
structure a name.
if (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK
LABEL while (EXPR) BLOCK
LABEL until (EXPR) BLOCK continue BLOCK
LABEL for (EXPR; EXPR; EXPR) BLOCK
LABEL foreach VAR (LIST) BLOCK continue BLOCK
9. Compound Statements
• Examples:
use strict; use warnings; $ = $/;
use strict; use warnings; $ = $/;
unless( open(FH,$0)){
die 'I do not exist on disk!'. $^E
}
else {
local $ = undef;#slurp mode
my $c=1;
print "$0: ", sprintf('%02d',$c++), " $_" while <FH>;
}
print $/.'---';
my $hashref = {me=>1,you=>2,he=>3};
exists $hashref->{she}
and print 'she: '.$hashref->{she}
or print 'she does not exists.'
and print sort values %$hashref;
10. Compound Statements
(2)
• Examples:
my $c = 0;
while ($c <= 10){
print $c;
}
continue {
$c++;
print $c;
};
########################################
A_LABEL: for my $m (1..10){
ANOTHER: for my $s(0..60) {
last A_LABEL if $m > 4;
last if $s > 4 and print '---';
print sprintf('%1$02d.%2$02d',$m,$s) ;
}
}
11. Comments and POD
• Text from a "#" character until the end of the line is a
comment
Exceptions include "#" inside a string or regular expression.
• POD is a simple-to-use markup language used for writing
documentation for Perl, Perl programs, and Perl modules.
use strict; use warnings; $ = $/;
my $simple = 'A simple statement.#not a comment.';
print $simple;#this is a comment
$simple =~ s#a##ig;
print $simple;
$simple =~ s/#//ig;
print $simple;
=pod
I like to use POD for multi-line comments
but it is much more than that.
=cut
print $0 . ' finished.';
13. Conditional Statements
• Truth and Falsehood
• The number 0, the strings '0' and '', the
empty list (), and undef are all false in a
boolean context
• All other values are true
• Negation of a true value by ! or not returns a
special false value.
When evaluated as a string it is treated as '',
but as a number, it is treated as 0.
14. Conditional Statements
• if/elsif/unless/else
use strict; use warnings; $ = $/;
unless( open(FH,$0) ){
die 'I do not exist on disk!'. $^E
}
else {
local $ = undef; my $c = 1;
print "$0: ", sprintf('%02d',$c++), " $_"
while <FH>;
}
my $hashref = {me=>1,you=>2,he=>3};
if ( exists $hashref->{she} ) {
print 'she:'.$hashref->{she};
}
else {
print 'she does not exists.';
print sort values %$hashref;
}
15. Conditional Statements
• Statement modifiers (suffix notation)
use strict; use warnings; $ = $/;
{
my $c=1;
local $ = undef;
do {
print "$0: ", sprintf('%02d',$c++), " $_"
while <FH>
} if open(FH,$0)
or die 'I do not exist on disk!'. $^E;
}
my $hashref = {me=>1,you=>2,he=>3};
print 'she:'.$hashref->{she}
if ( exists $hashref->{she} );
do {
print 'she does not exists.';
print sort values %$hashref;
} unless exists $hashref->{she};
16. Loops and Loop Control
• Loops
• for
• foreach
• while
• until
• do while/until
17. Loops and Loop Control
• for
• Perl's C-style for loop works like the
corresponding while loop
for ($i = 1; $i < 10; $i++) {
...
}
is (almost) the same as
$i = 1;
while ($i < 10) {
...
} continue {
$i++;
}
18. Loops and Loop Control
• foreach
• Iterates over a normal list value and sets the variable
VAR to be each element of the list in turn
• If preceded with my, it is visible only within the loop
• Otherwise, the variable is implicitly local to the loop
and regains its former value upon exiting the loop
• If VAR is omitted, $_ is set to each value
• You can use foreach for readability or for for
brevity
19. Loops and Loop Control
• foreach – Example:
my @pets = qw|Goldy Amelia Jako|;
my $favorite = 'Puffy';;
foreach $favorite(@pets) {
print 'My favourite pet is:' . $favorite;
}
print 'My favourite pet is:' . $favorite;#Puffy
for $favorite(@pets) {
print 'My favourite pet is:' . $favorite;
}
print 'My favourite pet is:' . $favorite;#Puffy
unshift @pets,$favorite;
for (@pets) {
print 'My favourite pet is:' . $_;
}
#...
20. Loops and Loop Control
• while
repeats a block of code as long as a condition is
true
• do while
executes the do at least once before evaluating
condition in while
$|++;# enable $OUTPUT_AUTOFLUSH
my @sufx = qw(th st nd rd th th th th th th th);
my $i = 1;
while ($i<=10) {
print "This is $i$sufx[$i] iteration";
sleep 1;
$i++;
}
do { print "The $i became $i" } while $i < 10;
print '- ' x $c, $c and $c++ while ($c<=10);
21. Loops and Loop Control
• until
repeats a block of code as long as a condition
is NOT true
• do until
executes the do at least once before evaluating
condition in until
$|++;# enable $OUTPUT_AUTOFLUSH
my @sufx = qw(th st nd rd th th th th th th th);
$i = 10;
until ($i<1) {
print "This is $i$sufx[$i] countdown";
sleep 1;
$i--;
}
do {print "T$i became $i"; $i--} until $i < 1;
22. Loops and Loop Control
• Loop control
• next
• last
• redo
• continue
23. Loops and Loop Control
• Loop control
• next
starts the next iteration of the loop
(continue in C)
• last
immediately exits the loop (break in C)
• redo
restarts the loop block without evaluating
the conditional again
• continue
is always executed just before
the conditional is about to be evaluated again
24. Loops and Loop Control
• Loop control
• next
• If LABEL is omitted, refers to the innermost
enclosing loop
• cannot be used to exit a block which
returns a value such as
eval {}, sub {} or do {}
• should not be used to exit
a grep() or map() operation
25. Loops and Loop Control
(2)
• Loop control
• next
my $c = 1;
while (<DATA>){
next unless /perl/;
chomp and print "$c: $_";
$c++;
}
__DATA__
This section of a perl file
can be used by the perl program
above in the same file to store
and use some textual data
perl rocks!!!
Will the above line print if we remove this one?
26. Loops and Loop Control
• Loop control
• last
• If LABEL is omitted, refers to the innermost
enclosing loop
• cannot be used to exit a block which
returns a value such as
eval {}, sub {} or do {}
• should not be used to exit a grep() or map()
operation
27. Loops and Loop Control
(2)
• Loop control
• last
my $c = 1;
while (<DATA>){
last unless /perl/;
chomp and print "$c: $_";
$c++;
}
__DATA__
This section of a perl file
can be used by the perl program
above in the same file to store
and use some textual data
perl rocks!!!
28. Loops and Loop Control
• Loop control
• redo
• skips the remaining BLOCK
• does not execute any continue block
(even if it exists)
• If the LABEL is omitted, the command refers
to the innermost enclosing loop
• cannot be used to retry a block which returns
a value such as eval {}, sub {} or do {}
• should not be used to exit a grep() or map()
operation
29. Loops and Loop Control
(2)
• Loop control
my ($c, $redone) = (1,0);
• redo while (<DATA>){
chomp; print "$c: $_"; $c++;
if ($_ =~ /perl/ and not $redone) {
$redone++;
redo;
}
elsif($_ =~ /perl/ and $redone) {
$redone--;
next;
}
}
__DATA__
This section of a perl file
can be used by the perl program
above in the same file to store
and use some textual data
perl rocks!!!
30. Loops and Loop Control
• Loop control
• continue
• can be used to increment a loop variable,
even when the loop has been continued via
the next statement
• last, next, or redo may appear within a
continue block
• last, next(!), and redo will behave
as in the main block
31. Loops and Loop Control
• Loop control
• continue
my ($c,$reached_10) = (1,);
while ($c) {
print '- ' x $c, $c;
} continue {
last if ($c == 1 and $reached_10);
$c-- if $reached_10;
$c++ if $c < 10 and not $reached_10;
$reached_10++ if $c == 10;
}
32. Logical Operators
• &&/and
• Binary "and" returns the logical conjunction of
the two surrounding expressions.
• and is equivalent to && except for the very low
precedence
• the right expression is evaluated only if the left
expression is true
my ($me,$you) = qw(me you);
print 'We are here:'.($me && $you) if ($me && $you);
print 'We are here:'.($me and $you) if ($me and $you);
undef $me;
print 'We are here:' if ($me and $you)
or die 'Someone';
33. Logical Operators
• ||/or
• Binary or returns the logical disjunction
of the two surrounding expressions
• or is equivalent to || except for the very
low precedence
• the right expression is evaluated only if
the left expression is false
• use or only for control flow
34. Logical Operators
• ||/or
Example:
my ($me,$you) = qw(me you);
print 'Somebody is here:'.($me || $you)
if ($me || $you);
print 'Somebody is here:'.($me or $you)
if ($me or $you);
($me,$you) = ('me', undef);
print 'Somebody is here:'.($me or $you)
if ($me or $you) or die 'Nooo..';
($me,$you) = (undef, 'you');
print 'Somebody is here:'.($me or $you)
if ($me or $you) or die 'no one';
35. Logical Operators
• !/not
• Unary "not" returns the logical negation
of the expression to its right
• the equivalent of "!" except for the very
low precedence
use Config;
print 'Do my perl uses old threads?';
print 'No' if !$Config{use5005threads};
print 'I do not have extras' if !$Config{extras};
print 'I do not have mail' if not $Config{mail};
36. Logical Operators
• The Ternary Operator, ?:
• ?: is an if-then-else test, all in one
expression
• "ternary" – takes three operands
• if the first expression is true, the second is
evaluated, the third is ignored
• if the first expression is false, the second is
ignored, and the third is evaluated as the
value of the whole
1 < 2 ? print 'true' : print 'false';
37. Mathematical Operators
• Additive Operators
• Binary "+" returns the sum of two
numbers
• Binary "-" returns the difference of two
numbers
• Note: Binary "." concatenates two strings
print 3+2;
print 2-3;
print 2.3; #;)
print '2'.'3';
38. Mathematical Operators
• Multiplicative Operators
• Binary "*" multiplies two numbers
• Binary "/" divides two numbers
• Binary "%" computes the modulus of two
numbers
• Binary "x" is the repetition operator
print 3 * 2;
print 2 / 3;
print "oddn" if 3 % 2; #;)
print 2 x 3;
39. Mathematical Operators
• Exponentiation
• Binary "**" is the exponentiation operator
• binds more tightly than unary minus, so
-2**4 is -(2**4), not (-2)**4
• Auto-increment and Auto-decrement
• "++" and "--" work as in C
print -2**4;#-16
my $a = 2;
print $a++; #2
print ++$a; #4
print $a--; #4
print --$a; #2
40. Operator Precedence
and Associativity
• Operator precedence means some operators are
evaluated before others.
• Operator associativity defines what happens if a
sequence of the same operators is used one after
another: whether the evaluator will evaluate the left
operations first or the right.
• See perlop/Operator Precedence and Associativity
#precedence
2 + 4 * 5 == 2 + 20 == 22 and not 6 * 5 == 30
#associativity
8 - 4 – 2 == 4 - 2 == 2 and not 8 - 2 == 6
41. Operator Precedence
and Associativity
• listed from highest precedence to lowest
• operators borrowed from C keep the same precedence
relationship with each other
left terms and list operators (leftward)
left ->
nonassoc ++ --
right **
right ! ~ and unary + and -
left =~ !~
left * / % x
left + - .
left << >>
nonassoc named unary operators
nonassoc < > <= >= lt gt le ge
nonassoc == != <=> eq ne cmp ~~
...
to be continued
42. Operator Precedence
and Associativity
(2)
• Many operators can be overloaded for objects.
• See the overload manpage
...
continued
left &
left | ^
left &&
left || //
nonassoc .. ...
right ?:
right = += -= *= etc.
left , =>
nonassoc list operators (rightward)
right not
left and
left or xor
43. Error Handling
• die
• warn
• eval{statements()};
do{something()} if($@)
warn 'Default variable is undefined' unless $_;
eval ' a syntax error or any failure';
if($@){
warn 'You spoiled everything';
}
44. Error Handling
• Carp
• carp - warn of errors
(from perspective of caller)
• cluck - warn of errors with stack backtrace
(not exported by default)
• croak - die of errors
(from perspective of caller)
• confess - die of errors with stack backtrace
45. Error Handling
• Carp – Example:
use Carp qw(cluck croak confess);
other_place();
croak "We're outta here!";
sub here {
$ARGV[0] ||= 'try';
if ($ARGV[0] =~ /try/){
cluck "nThis is how we got here!"
}
elsif ($ARGV[0] =~ /die/){
confess "nNothing to live for!";
}
}
sub there { here; }
sub other_place { there }
47. Exercises
1. Write a program that iterates from 3 to 15 and then
from 15 to 3. Print every iteration on the screen.
Try to write it from scratch.
2. Write a program that dies with an error message if
the argument on the command line contains the
word “die”.
3. Write a program that tries to guess the argument
to the script if it contains the numbers 1 or 2 and
prints different messages depending on the
argument. Try not to use if/elsif/unless/else.