Chapter 2-3 Flashcards

1
Q

== or eq

A

exactly equal to

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

!=

A

not equal to

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

ne

A

not equal to

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

if loop

A

if ($hour == 12) {
print “Lunchtime!\n”;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

if/else loop

A
if ($hour == 12) {
 print “Lunchtime!\n”;
} else {
 print “I'm hungry.\n”;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

if/elsif/else loop

A
if ($hour == 12) {
 print “Lunchtime!\n”;
} elsif ($hour == 6) {
 print “Dinner!\n”;
} else {
 print “I'm hungry.\n”;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

while loop

A

while ($hour

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

for loop

A

for ($hour = 0; $hour

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

foreach loop

A

foreach $icount (10..1) {
print “$icount “;
}
print “Blastoff.\n”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Functions– things that

A
  • do something to their inputs
  • then return the result
  • use () to hold their goodies.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

function with return value

A

$return_value = function_name($var1, $var2, $var3);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

@icount = (1, 2, 3, 4, 5);

A

building a list of items

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

List =

A

an ordered collection of scalars

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Array =

A

ordered collection of scalars

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Indices always start at

A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

access array element

A

$name[0] = “words”;

17
Q

finding the index of the last element

A

print $#rocks; # prints 2

18
Q

finding the last element in an array

A
$# = 'last element'
OR
$rocks[0] = “bedrock”;
$rocks[1] = “slate”;
$rocks[2] = “lava”;
print $rocks[$#rocks]; # prints “lava”;
19
Q

walking through a list: foreach

A

foreach $item (@array) {
print “I am looking at $item.\n”;
}

20
Q

listing literals

A

@alist = (1, 2, 3); # list of three values 1, 2, and 3

21
Q

qw

A

@alist = qw( fred barney betty wilma dino );