Control Structures

if statement

	if (expression) {
	     do_something;
	     do_something_more;
	} 

if/else statement

	if (expression) {
	   do_something;
	} else {
	     do_somethingelse;
	}

if/elseif/else statement

	if (expression_A) {
	     do_something;
	} elseif (expression_B) {
	     do_something_else;
	} else {
	     do_something_totally_different;
	}

while statement (do something as long the exp is true)

	while (expression) {
	     do_something;
	}

until statement

	until (expression) {  
	  do_something;
	}

for statement ( for (initial exp; test exp; increment exp) )

	for($i=1; $i<5; $i++)
	    do_something_4_times;
	}

foreach statement

	 foreach $i (@aList) {
	     $aList[0] = "ABC";
	     $aList[1] = "DEF";
	i++;
	}

foreach statement example

	@aList = ("First","Second","Third");
	foreach $element (@aList) {
	print "$element\n";
	}

Go to perl-page 6 ... Back to perl-page 4 ... Starting page