programming-examples/perl/Statement
2019-11-15 12:59:38 +01:00
..
@numbers = ( 1 .. 10 ).pl Initial commit 2019-11-15 12:59:38 +01:00
$_ takes the place of the control variable.pl Initial commit 2019-11-15 12:59:38 +01:00
A do statement.pl Initial commit 2019-11-15 12:59:38 +01:00
A program containing a simple example of an if statement.pl Initial commit 2019-11-15 12:59:38 +01:00
A program that demonstrates the while statement.pl Initial commit 2019-11-15 12:59:38 +01:00
A program that loops using a single-line conditional statement.pl Initial commit 2019-11-15 12:59:38 +01:00
A program that uses the if-else statement.pl Initial commit 2019-11-15 12:59:38 +01:00
A program that uses the if-elsif-else statement.pl Initial commit 2019-11-15 12:59:38 +01:00
A program that uses the until statement.pl Initial commit 2019-11-15 12:59:38 +01:00
A while loop is often used to read from a file until there is no more data available.pl Initial commit 2019-11-15 12:59:38 +01:00
A word-counting program that uses the next statement.pl Initial commit 2019-11-15 12:59:38 +01:00
A word-counting program that uses the redo statement.pl Initial commit 2019-11-15 12:59:38 +01:00
Analysis of sales results.pl Initial commit 2019-11-15 12:59:38 +01:00
Average-sales problem with counter-controlled repetition.pl Initial commit 2019-11-15 12:59:38 +01:00
Average-sales problem with sentinel-controlled repetition.pl Initial commit 2019-11-15 12:59:38 +01:00
Breaking Out.pl Initial commit 2019-11-15 12:59:38 +01:00
Choosing an Iterator.pl Initial commit 2019-11-15 12:59:38 +01:00
Conditional Control Statements.pl Initial commit 2019-11-15 12:59:38 +01:00
Conditional Modifiers and print.pl Initial commit 2019-11-15 12:59:38 +01:00
Conditional Modifiers- The if Modifier.pl Initial commit 2019-11-15 12:59:38 +01:00
Conditional operator- The unless Modifier and while loop and __DATA__.pl Initial commit 2019-11-15 12:59:38 +01:00
Conditional operator- The unless Modifier.pl Initial commit 2019-11-15 12:59:38 +01:00
Controlling Loop Flow.pl Initial commit 2019-11-15 12:59:38 +01:00
Count 10 with while loop.pl Initial commit 2019-11-15 12:59:38 +01:00
Counting Up And Down.pl Initial commit 2019-11-15 12:59:38 +01:00
Create an infinite loop using a for loop.pl Initial commit 2019-11-15 12:59:38 +01:00
Declare variable in foreach statement.pl Initial commit 2019-11-15 12:59:38 +01:00
Demonstrating the .. operator.pl Initial commit 2019-11-15 12:59:38 +01:00
Do .. while statement.pl Initial commit 2019-11-15 12:59:38 +01:00
Duplicate of the foreach structure with for structure.pl Initial commit 2019-11-15 12:59:38 +01:00
Duplicate the for structure with the foreach keyword.pl Initial commit 2019-11-15 12:59:38 +01:00
Each time through the loop, foreach places the next element of the list into the scalar variable.pl Initial commit 2019-11-15 12:59:38 +01:00
Example of foreach from a min to a max.pl Initial commit 2019-11-15 12:59:38 +01:00
Example using the continue block.pl Initial commit 2019-11-15 12:59:38 +01:00
Exit a loop.pl Initial commit 2019-11-15 12:59:38 +01:00
Exits using the last statement.pl Initial commit 2019-11-15 12:59:38 +01:00
Extend the if statement to include an else block.pl Initial commit 2019-11-15 12:59:38 +01:00
For each loop with array and $_.pl Initial commit 2019-11-15 12:59:38 +01:00
For each loop with array.pl Initial commit 2019-11-15 12:59:38 +01:00
foreach (1 .. 10) range.pl Initial commit 2019-11-15 12:59:38 +01:00
foreach ( 1 .. 10 ) loops 10 times, not requiring a control variable.pl Initial commit 2019-11-15 12:59:38 +01:00
foreach and array.pl Initial commit 2019-11-15 12:59:38 +01:00
foreach Loop Array Processing.pl Initial commit 2019-11-15 12:59:38 +01:00
foreach Loop Hash Processing in a CGI Program.pl Initial commit 2019-11-15 12:59:38 +01:00
foreach Loop Hash Processing.pl Initial commit 2019-11-15 12:59:38 +01:00
foreach statement with number range.pl Initial commit 2019-11-15 12:59:38 +01:00
foreach statement.pl Initial commit 2019-11-15 12:59:38 +01:00
From to.pl Initial commit 2019-11-15 12:59:38 +01:00
Going onto the Next.pl Initial commit 2019-11-15 12:59:38 +01:00
Goto statement with label.pl Initial commit 2019-11-15 12:59:38 +01:00
he while, until, and do Statements.pl Initial commit 2019-11-15 12:59:38 +01:00
Here is an example of the for loop.pl Initial commit 2019-11-15 12:59:38 +01:00
If and else.pl Initial commit 2019-11-15 12:59:38 +01:00
if in a while loop.pl Initial commit 2019-11-15 12:59:38 +01:00
if scope.pl Initial commit 2019-11-15 12:59:38 +01:00
If start with - no repeat.pl Initial commit 2019-11-15 12:59:38 +01:00
If statement and integer comparsion.pl Initial commit 2019-11-15 12:59:38 +01:00
If statement in a while statement.pl Initial commit 2019-11-15 12:59:38 +01:00
If statement ladder.pl Initial commit 2019-11-15 12:59:38 +01:00
If statement with else.pl Initial commit 2019-11-15 12:59:38 +01:00
If statement with scalar variable.pl Initial commit 2019-11-15 12:59:38 +01:00
if statement.pl Initial commit 2019-11-15 12:59:38 +01:00
If you declare your iterator outside the loop, any value it had then will be restored afterwards.pl Initial commit 2019-11-15 12:59:38 +01:00
if-else statement.pl Initial commit 2019-11-15 12:59:38 +01:00
if-elsif statement.pl Initial commit 2019-11-15 12:59:38 +01:00
Initialization, test, and increment, decrement of counters is done in one step.pl Initial commit 2019-11-15 12:59:38 +01:00
Labels Create an infinite loop to demonstrate how last will break out of multiple code blocks.pl Initial commit 2019-11-15 12:59:38 +01:00
last if.pl Initial commit 2019-11-15 12:59:38 +01:00
last statement inside an if statement.pl Initial commit 2019-11-15 12:59:38 +01:00
last statement.pl Initial commit 2019-11-15 12:59:38 +01:00
Last with label.pl Initial commit 2019-11-15 12:59:38 +01:00
Letter based range.pl Initial commit 2019-11-15 12:59:38 +01:00
Loop Control Statements.pl Initial commit 2019-11-15 12:59:38 +01:00
Loop with label.pl Initial commit 2019-11-15 12:59:38 +01:00
Looping Modifiers- The while Modifier.pl Initial commit 2019-11-15 12:59:38 +01:00
Looping through an array with the for repetition structure.pl Initial commit 2019-11-15 12:59:38 +01:00
Looping Until.pl Initial commit 2019-11-15 12:59:38 +01:00
Looping While.pl Initial commit 2019-11-15 12:59:38 +01:00
Mix $_ and foreach statement.pl Initial commit 2019-11-15 12:59:38 +01:00
Mixed diamond operator with for loop condition 2.pl Initial commit 2019-11-15 12:59:38 +01:00
Mixed diamond operator with for loop condition.pl Initial commit 2019-11-15 12:59:38 +01:00
Nest if statement into for loop.pl Initial commit 2019-11-15 12:59:38 +01:00
Nested for loop.pl Initial commit 2019-11-15 12:59:38 +01:00
Next if.pl Initial commit 2019-11-15 12:59:38 +01:00
Next statement with if statement.pl Initial commit 2019-11-15 12:59:38 +01:00
Next statement.pl Initial commit 2019-11-15 12:59:38 +01:00
next with condition.pl Initial commit 2019-11-15 12:59:38 +01:00
Perl has a number of string comparison operators you can use in if statements.pl Initial commit 2019-11-15 12:59:38 +01:00
Plural format and ternary operator.pl Initial commit 2019-11-15 12:59:38 +01:00
Plural message.pl Initial commit 2019-11-15 12:59:38 +01:00
Plural output with if statement.pl Initial commit 2019-11-15 12:59:38 +01:00
Print out even numbers with a do...while loop.pl Initial commit 2019-11-15 12:59:38 +01:00
program that prints the numbers from 1 to 5 using the for statement.pl Initial commit 2019-11-15 12:59:38 +01:00
Put more than one statement first and third part of for statement.pl Initial commit 2019-11-15 12:59:38 +01:00
Range based on letter and digit- from 3 to z.pl Initial commit 2019-11-15 12:59:38 +01:00
Range based on letter and digit- from z to 3.pl Initial commit 2019-11-15 12:59:38 +01:00
Range based on letter.pl Initial commit 2019-11-15 12:59:38 +01:00
Range counting down.pl Initial commit 2019-11-15 12:59:38 +01:00
Range counting up.pl Initial commit 2019-11-15 12:59:38 +01:00
range list and for loop.pl Initial commit 2019-11-15 12:59:38 +01:00
Range Operator.pl Initial commit 2019-11-15 12:59:38 +01:00
redo statement.pl Initial commit 2019-11-15 12:59:38 +01:00
Reference array length in for loop.pl Initial commit 2019-11-15 12:59:38 +01:00
Reference for loop control variable.pl Initial commit 2019-11-15 12:59:38 +01:00
Setting elements in a list to equal the corresponding elements of another list with three different names.pl Initial commit 2019-11-15 12:59:38 +01:00
Standard for structure- Loops 5 times, printing the multiples of 5 from 0-20.pl Initial commit 2019-11-15 12:59:38 +01:00
Standard foreach structure, printing the values in a list.pl Initial commit 2019-11-15 12:59:38 +01:00
Standard foreach structure. Prints the letters A-G.pl Initial commit 2019-11-15 12:59:38 +01:00
String based range.pl Initial commit 2019-11-15 12:59:38 +01:00
Sums the numbers from 1 to a specified number and also sums the even numbers.pl Initial commit 2019-11-15 12:59:38 +01:00
Switch for data type.pl Initial commit 2019-11-15 12:59:38 +01:00
Switch on sub.pl Initial commit 2019-11-15 12:59:38 +01:00
The .. operator goes from a minimum to a maximum, with foreach.pl Initial commit 2019-11-15 12:59:38 +01:00
The continue block allows the while loop to act like a for loop.pl Initial commit 2019-11-15 12:59:38 +01:00
The continue block gets executed just before the condition gets evaluated again.pl Initial commit 2019-11-15 12:59:38 +01:00
The do-while and do-until Loops.pl Initial commit 2019-11-15 12:59:38 +01:00
The for Loop.pl Initial commit 2019-11-15 12:59:38 +01:00
The foreach Loop.pl Initial commit 2019-11-15 12:59:38 +01:00
The foreach modifier evaluates once for each element, with $_ aliased to each element.pl Initial commit 2019-11-15 12:59:38 +01:00
The foreach statement iterates through list values, assigning a variable the value of each element in turn.pl Initial commit 2019-11-15 12:59:38 +01:00
The foreach statement lets you iterate for each element in a list or array.pl Initial commit 2019-11-15 12:59:38 +01:00
The if Construct.pl Initial commit 2019-11-15 12:59:38 +01:00
The if-else Construct.pl Initial commit 2019-11-15 12:59:38 +01:00
The if-elsif-else Construct.pl Initial commit 2019-11-15 12:59:38 +01:00
The last statement breaks out of a loop from within the loop block.pl Initial commit 2019-11-15 12:59:38 +01:00
The or part allows for a statement to be executed if the main part fails.pl Initial commit 2019-11-15 12:59:38 +01:00
The Range Operator and Array Assignment.pl Initial commit 2019-11-15 12:59:38 +01:00
The range operator and foreach loop.pl Initial commit 2019-11-15 12:59:38 +01:00
The Switch.pm Module.pl Initial commit 2019-11-15 12:59:38 +01:00
The unless Construct.pl Initial commit 2019-11-15 12:59:38 +01:00
The unless statement is the opposite of if and executes a block unless a condition is true.pl Initial commit 2019-11-15 12:59:38 +01:00
The until Loop.pl Initial commit 2019-11-15 12:59:38 +01:00
The until modifier repeatedly executes the second expression as long as the first expression is false.pl Initial commit 2019-11-15 12:59:38 +01:00
The until statement.pl Initial commit 2019-11-15 12:59:38 +01:00
The while command.pl Initial commit 2019-11-15 12:59:38 +01:00
The while Loop.pl Initial commit 2019-11-15 12:59:38 +01:00
Two ranges.pl Initial commit 2019-11-15 12:59:38 +01:00
unless statement in while.pl Initial commit 2019-11-15 12:59:38 +01:00
unless statement with else.pl Initial commit 2019-11-15 12:59:38 +01:00
unless statement with elsif.pl Initial commit 2019-11-15 12:59:38 +01:00
unless statement.pl Initial commit 2019-11-15 12:59:38 +01:00
until statement.pl Initial commit 2019-11-15 12:59:38 +01:00
until with continue.pl Initial commit 2019-11-15 12:59:38 +01:00
until with diamond operator.pl Initial commit 2019-11-15 12:59:38 +01:00
until with integer.pl Initial commit 2019-11-15 12:59:38 +01:00
Use a label.pl Initial commit 2019-11-15 12:59:38 +01:00
Use an elsif statement to check if a different condition is true.pl Initial commit 2019-11-15 12:59:38 +01:00
Use for loop to output all elements in an array.pl Initial commit 2019-11-15 12:59:38 +01:00
Use for loop to output the element one by one in an array.pl Initial commit 2019-11-15 12:59:38 +01:00
Use foreach to loop through hash with keys function.pl Initial commit 2019-11-15 12:59:38 +01:00
Use if statement to check the integer value.pl Initial commit 2019-11-15 12:59:38 +01:00
Use range operator with for statement.pl Initial commit 2019-11-15 12:59:38 +01:00
Use until to read user input.pl Initial commit 2019-11-15 12:59:38 +01:00
Use while loop to read console input and replace.pl Initial commit 2019-11-15 12:59:38 +01:00
Use while loop to read console input.pl Initial commit 2019-11-15 12:59:38 +01:00
Uses the for statement to read four input lines and write three of them.pl Initial commit 2019-11-15 12:59:38 +01:00
Using .. to construct array.pl Initial commit 2019-11-15 12:59:38 +01:00
Using a label without a loop and the redo statement.pl Initial commit 2019-11-15 12:59:38 +01:00
Using a label.pl Initial commit 2019-11-15 12:59:38 +01:00
Using array length in foreach statement.pl Initial commit 2019-11-15 12:59:38 +01:00
Using block labels with next in nested looping structures.pl Initial commit 2019-11-15 12:59:38 +01:00
Using block labels with next.pl Initial commit 2019-11-15 12:59:38 +01:00
Using both next and continue.pl Initial commit 2019-11-15 12:59:38 +01:00
Using do .. until statement.pl Initial commit 2019-11-15 12:59:38 +01:00
Using for loop to sum the total.pl Initial commit 2019-11-15 12:59:38 +01:00
Using foreach loops with hashes.pl Initial commit 2019-11-15 12:59:38 +01:00
Using foreach statement with hash.pl Initial commit 2019-11-15 12:59:38 +01:00
Using foreach statement with print.pl Initial commit 2019-11-15 12:59:38 +01:00
Using foreach to iterate over an array.pl Initial commit 2019-11-15 12:59:38 +01:00
Using foreach to loop through an array without using the default value.pl Initial commit 2019-11-15 12:59:38 +01:00
Using foreach to loop through array variable.pl Initial commit 2019-11-15 12:59:38 +01:00
Using if statement to check if a variable has been defined.pl Initial commit 2019-11-15 12:59:38 +01:00
Using if statement to check if a variable is zero.pl Initial commit 2019-11-15 12:59:38 +01:00
Using if statement to check the number entered from keyboard.pl Initial commit 2019-11-15 12:59:38 +01:00
Using if statements with relational and equality operators.pl Initial commit 2019-11-15 12:59:38 +01:00
Using my inside for statement.pl Initial commit 2019-11-15 12:59:38 +01:00
Using nested for loop to assign value to two dimensional array.pl Initial commit 2019-11-15 12:59:38 +01:00
Using nested for loop to output the elements in a two-dimensional array.pl Initial commit 2019-11-15 12:59:38 +01:00
Using predefined variable $_ in foreach loop.pl Initial commit 2019-11-15 12:59:38 +01:00
Using the do-until repetition structure.pl Initial commit 2019-11-15 12:59:38 +01:00
Using the do-while repetition structure.pl Initial commit 2019-11-15 12:59:38 +01:00
Using the equality-comparison operator to compare two numbers entered at the keyboard.pl Initial commit 2019-11-15 12:59:38 +01:00
Using the goto statement.pl Initial commit 2019-11-15 12:59:38 +01:00
Using the if elsif statement to check the number entered from keyboard.pl Initial commit 2019-11-15 12:59:38 +01:00
Using the last statement in a foreach structure.pl Initial commit 2019-11-15 12:59:38 +01:00
Using the next statement in a foreach structure.pl Initial commit 2019-11-15 12:59:38 +01:00
Using the redo statement in a while structure.pl Initial commit 2019-11-15 12:59:38 +01:00
Using unless with regular expression.pl Initial commit 2019-11-15 12:59:38 +01:00
Using until with print statement.pl Initial commit 2019-11-15 12:59:38 +01:00
Using variable defined outside in foreach loop.pl Initial commit 2019-11-15 12:59:38 +01:00
Using while and for statement to check if you had typed in four letter words.pl Initial commit 2019-11-15 12:59:38 +01:00
Using While loop the output the elements in an array.pl Initial commit 2019-11-15 12:59:38 +01:00
Using while loop to calculate the number of lines in a file.pl Initial commit 2019-11-15 12:59:38 +01:00
Using while loop with each.pl Initial commit 2019-11-15 12:59:38 +01:00
Using while statement to check the entered value from keyboard.pl Initial commit 2019-11-15 12:59:38 +01:00
Using while statement to read from keyboard.pl Initial commit 2019-11-15 12:59:38 +01:00
while and until loop.pl Initial commit 2019-11-15 12:59:38 +01:00
while data section.pl Initial commit 2019-11-15 12:59:38 +01:00
While loop and counter.pl Initial commit 2019-11-15 12:59:38 +01:00
While loop counter.pl Initial commit 2019-11-15 12:59:38 +01:00
While loop, foreach loop, and block and redo.pl Initial commit 2019-11-15 12:59:38 +01:00
While statement and scalar control value.pl Initial commit 2019-11-15 12:59:38 +01:00
while statement to read input.pl Initial commit 2019-11-15 12:59:38 +01:00
while-until Loop.pl Initial commit 2019-11-15 12:59:38 +01:00
You can use a for loop to loop for a specific number of times.pl Initial commit 2019-11-15 12:59:38 +01:00