Gavilan

CSIS054: Perl Programming

Questions for week 2

 

QUESTION ANSWER
(highlight to read)
What steps can you take if you get errors on a script? Read the errors. Get the line number. Insert print statements.
What effect does the name of the variable you choose have? No effect.
How do you get rid of a "\n" (newline) at the end of a string? chomp function.
Where would I look up how a function in the standard library works? perlfunc page. (google it)
How do you call a function? &function_name(arg);
How do you save the results of a function? $var = function(arg);
How do you delineate a string? A pair of single or double quotes.
What's the difference between using single or double quotes? Double quotes do variable interpolation and expand control characters like "\n".
What are some values that are false? Zero. An empty string. UNDEF.
What are the operators for add, subtract, multiply, and divide? + - / *
What's the difference between == and eq?

== is for numbers,
eq is for strings.

What's the difference between == and =? == is a comparison.
= is an assignment.
How do I combine two strings into one? . (dot) concatenation operator

What's the value of $a after this code runs?
    $a=5; $a*=5;

25
How do you repeat a statement 5 times? $a=5;
while($a>0) {
   $a--;
   __STATEMENT__
}
   

 

 

 



Address of this page is http://hhh.gavilan.edu/phowell/csis054/02questions.html
Please contact Peter Howell at phowell@gavilan.edu for questions or comments.
Last updated January 10, 2010.