Search
 
SCRIPT & CODE EXAMPLE
 

PERL

Perl - Common Conditional Statements

#if, elseif, else

if ($myNumber == 5)
{
    print "My Number is Five 
";
}

elsif ($myNumber == 3.14)
{
    print "My Number is Pi 
";
}

else
{
    print "My Number is neither Five nor Pi 

"
}


#while loop
while ($myNumber != 0) #could do: until ($myNumber == 0)
{
    print "My Number is: ", $myNumber, "
";
    $myNumber -= 1;
}

print "
";

#for loop
for ($myNumber = 0; $myNumber < 5; $myNumber++)
{
    print "My Number is: ", $myNumber, "
";
}

print "
";

#foreach loop
foreach my $currentElement (@myList)
{
    print "The current element is: ", $currentElement, "
";
}
Comment

PREVIOUS NEXT
Code Example
Perl :: perl running mechanize through tor 
Pascal :: pascal input 
Pascal :: wait for input in pascal 
Pascal :: pascal error handling 
Pascal :: while do in pascal 
Pascal :: does not equal in pascal 
Powershell :: windows 10 debloat 
Powershell :: Download attachment from Jira task to local filesystem 
Gdscript :: godot get global position 3d 
Gdscript :: gdscript dictionary 
Clojure :: folding at home linuxserver.io 
Cobol :: google apps script remove nulls array 
Assembly :: jinja loop index 
Assembly :: error: ‘cv’ is not a namespace-name using namespace cv; 
Assembly :: how to listen for changes on an ObservableMap 
Assembly :: fatal error: opencv2/core/version.hpp: No such file or directory 
Javascript :: jquery vslidation remove spaces from input 
Javascript :: map range of numbers to another range 
Javascript :: jest cache clear 
Javascript :: javascript replace spaces with dashes 
Javascript :: import redux thunk 
Javascript :: jquery refresh page 
Javascript :: delete session javascript 
Javascript :: get week day name in javascript 
Javascript :: how to remove checked attribute of checkbox in jquery 
Javascript :: loop array backwards javascript 
Javascript :: generate random whole numbers within a range javascript 
Javascript :: jquery remove and add class 
Javascript :: how to use another port in angular 
Javascript :: How to get current URL with Javascript or React 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =