Study your flashcards anywhere!

Download the official Cram app for free >

  • 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

How to study your flashcards.

Right/Left arrow keys: Navigate between flashcards.right arrow keyleft arrow key

Up/Down arrow keys: Flip the card between the front and back.down keyup key

H key: Show hint (3rd side).h key

A key: Read text to speech.a key

image

Play button

image

Play button

image

Progress

1/24

Click to flip

24 Cards in this Set

  • Front
  • Back
What should you put at the top of a perl program to make it a perl program in unix and also allow it to print warnings.
#!/usr/bin/perl -w
What is the general definition of a scalar in Perl. What are some examples of a scalar?
As a general rule, when perl has just one of something, that is a scalar.

Most scallars are either a number (like 255 or 3.25e20) or a string of characters (like "hello" or the getysburg address)
What format are numbers stored as internally in Perl?
Perl computes ALL numbers with double precision floating-point values. Double precision is defined by the C compiler for the machine that compiled your perl interpretter. Ussually has 15 digits worth of precision and a range e-100 to e+100. This means that there are no integer values as far as perl is concerned.
How might you clarify the human reading of a really long integer in Perl?
Perl allows you to place underscore '_' characters in a number, these will no be seen by the perl compiler.

example) 61_298_040_283_768
How do you specify a Nondecimal Integer literal in base 10, binary, and hex respecively?
0377 #377 octal, same as 255 decimal
0xff #FF hex, also 255 decimal
0b11111111 #also 255 decimal, in binary
What is 10.5 % 3.2 in Perl?
it is 1, because 10.5 and 3.2 are converted to 10 and 3 respectively.
What is the exponential operator in Perl?
The exponential operator is **, usage is 2**3 (should equal 8).
What does perl use to determine when it has reached the end of a string?
Perl uses length counting, not a null character, to determine the length of a string. Null in no way indicates the length of a string in perl.
What is a single quoted string literal?
A single quoted string literal is a sequence of characters enclosed in single quotes. Any character except a backslash and single quote stands for itself inside a string.

Examples:
'fred'
'Don't'
'hello\n' #oddly prints hello\n
What is a double quoted string literal?
A double quoted string literal is a series of characters enclosed in double quotes. However, now the backslash takes on its full power to specify other characters.

"barney" #just the same as 'barney'
"hello world/n" #hello world and a newline
"coke\tsprite" #coke, a tab, and sprite
Is "Barney" the same as 'barney' to Perl?
yes, it is like the difference between 255 and octal 377, same thing, just looks different.
String concatenation, how is it done?
String concatenation is done with the . symbol.

Examples:
"Hello"."world" #same as "Helloworld"
"hello".' '."world" #same as 'hello world'
'hello world'."\n" #same as "hello world\n"
What is the string repetition operator? How does it work?
The string repetition operator repeats a string a certain number of times.

Example:
"fred" x 3 #"fredfredfred"
"barney" x (4+1) #barneybarneybarneybarneybarney"
5 x 4 # is really "5" x 4, which is "5555"
How are scalar variables in perl referenced?
Scalar variables in perl are always referenced with the leading $. The shell sometimes you don't use the $VariableName to get the value.
What is variable interpolation?
Specifically?
What happens when you use a variable that has not been filled in?
What happens when you mix and match double and single quoted variables?
How do you put a variable into a statement and NOT make the variable evaluate as a variable?
If a variable has not been given a article the variable returns the empty string.
It appears that it always become double quoted.
print 'The name is $fred'."\n"; == "The name is \$fred.\n"; # prints a dollar sign
What type of mathematical operator precedence does perl follow?
For mathematical operators, Perl will evaluate them according to normal mathematical rules. For other operators, consult the table on p32.
What types of Algebraic Operators does Perl use?
What types of String Operators does Perl use?
Comparison Numeric String
-----------------------------------------
Equal == eq
Not Equal != ne
Less Than < lt
Greater Than > gt
Less than & Equal <= le
Greater Than & Equal >= ge
how do you use the if Control Structure in Perl? What is different about the curly braces compared to C++ or Java? What value must be in the evaluation portion of the if?
if(Evaluation){
#if true
}else {
#if false
}

Evaluation must be a scalar. Unlike in C++ and Java, the curly braces are required statements.
What are the four existent scalar values that are false?
undef, 0, '', or '0' are the only false scalar values. All other scalar values are true.
How do you get user input in perl?
Use the line input operator <STDIN>. The <STDIN> operator gets the next line of text from your system, if there is nothing waiting to be read, it will wait for the next line of input. A newline is generally appended to the end of the line by <STDIN>

Example:
$line = <STDIN>; #puts line of text in $line
How function removes the newline character from a string? What does it return? What does it do if there is no newline character?
use the chomp function. it will return the number of characters removed. If there is no newline, it does nothing and returns nothing.

Example:
chomp($text = <STDIN>); #gets next line w/out newline character
chomp $text; #for some reason this works as well.
What are the specifications for the while control structure?
while (THIS_VALUE_IS_TRUE){
#Execute this
}

like if() the block curly braces are required.
What is the undef Value?
The undef Value is most common the value assigned to variables when they have been declared but have not been given a value. It will evaluate to zero or the empty string depending on context.
What does the defined function do? What is it ussually used for?
The defined function returns true for all variables that are not set to undef. Because when reading a file, the end of file is marked by returning the undef function, the defined function can be used to determine that no input was available.

Example:
defined($madonna) #true if defined, false if $madone contains undef.