Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
A while generally does not do this. It simply tests whether some condition is true. For example:Foreach takes an array, and returns all the values of the array in a scalar
@interests=("golf","tennis","fencing","blacksmiths");
for (@interests) {
# each elem of @interests returned 1 at a time in $_
...
}
while (@interests) {
# Does not return a list element.
# Just tests for "true" (non-zero/non-null) value.
# Results in [b]endless loop[/b] if [b]@interests[/b]
# is not empty and not modified within the loop
...
}
my $i = 0;
while (defined($interests[$i++])) {
...
}
#foreach
foreach $keys (keys(%hash)) {
# gives you only keys. With values, the foreach loop
# gets even more complicated.
}
# while
while (($keys,$values) = each(%hash)) {
# lets you use both values of a hash, more easily
}