• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/18

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

18 Cards in this Set

  • Front
  • Back
Give an example of declaring multiple variables.
my ($a, %b, @c);
Note that the parentheses are required when declaring multiple variables on one line. due to the lower precedence of my to a ,.
What does chomp() do?
It removes all new lines if a string has one, otherwise it does nothing. It returns the number of newlines removed.
What does the exists function do?
It determines if a hash key exists.
exists $hash{$key;
returns 1 or 0
What does the defined function do?
It determines if a variable has a value.
defined $a;
What does unless do?
It is equivalent to - if not.
What is a statement modifier?
It has the form <action> if <condition>.
example:
die "Stupid mistake" unless exists $smart;
How do you use "or" to execute a conditional action?
exists $something or print "nothing";
Left side is evaluated first, and if it isn't true then the right hand side is evaluated.
How do you use "and" to execute a conditional action?
exists $something and print "something";
If left side and right side are true then it will execute right side.
What is a good way to execute one of many different options without using if elseif?
for ($branch){
$_ == 1 && print "1 \n";
$_ == 2 && print "2 'n";
...
}
Are for and foreach equivalent?
Yes.
What is the difference between declaring the iterator variable outside the loop or in the loop.
If it is outside the loop it will return to the value it had before the loop was executed after the loop completes. If inside it will only exist while the loop is iterated.
What does "$total += $_ for @ARGV;" do?
It sums up all the arguments from the input and assigns the value to the $total variable.
How do you modify the while statement?
<actions> while <condition>
print "something" while $countdown-- > 0;
What does the until command do?
It is the opposite of while meaning <not condition>
What does the last statment do?
It will break out of a loop if condition is true.
while(1){
last if 1;
}
What does the next statement do?
It stops executing the rest of the body instructions and begins a new loop iteration.
What does the redo statement do?
It reruns the body of the loop without iterating.
What do loop labels allow you to do?
You can give each loop a name and when you do a last you can exit out of the loop name in the last statement.