Using for statement

วันจันทร์ที่ 14 กันยายน พ.ศ. 2552

- for (;;;) are used as models. (If the language used through PHP, C or some other language, the language may be familiar with this syntax).

for ($i = 1; $i <10; $i++) (
)

# $i mean set to start as 1 and checks that $i is not less than 10 or if less than 10, follow the instructions on the blog. When instructions complete in block (in each round) is the variable $i++ (the plus to add 1) and then check the conditions.

- using "for" statement for display value of all member in array.

for $value (@array) (

print $value;

)


- Displaying keys in member of array.

for $i (keys %array) (

print $i;

)

# For displaying value of all member in array by using keys reference.

for $i (keys %array) (

print $array ($i);

)

0 ความคิดเห็น:

แสดงความคิดเห็น

 
 
 
 
Copyright © Basic Perl