New

Long-Term Learning

Learn efficiently and remember over time.

Start Long-Term Learning

Get personalized study reminders at intervals optimized for better retention.
Track your progress on this set by creating a folder
Or add to an existing folder

Add this set to a folder

  • Identify the two phases of creating a PERL program

    1. Editing
    2. Execution

    Identify what modules are in perl

    - Synonymous with header files in C
    - Collection of like functions and variables that may be used in your program

    Identify how to include modules in perl

    use moduleName;
    Ex: use Roman;

    Identify the interpreters role in handling syntax errors

    - In perl, the interpreter will recognize syntax errors and halt execution BEFORE it begins
    - Interpreter will output statements; it does not understand and the line which it encountered the error on

    Identify the use of comments in perl

    - Documenting code
    - Created by placing a "#" on a line.
    - Comments are not multi-line

    Explain variable context in perl

    - can be scalar, array, or hash context
    - tells the interpreter what you are looking for (Ex: "$arrayname[$index_number]")

    Describe scalar variables in perl

    - Singular variable, starts with "$"
    - Number, characer or string
    - Perl does automatic type conversion of scalar variables

    Describe array variables in perl

    - A collection of data (static data, scalar variables, arrays or hashes can all be stored in an array element)

    Describe hash variables in perl

    - An associative array

    Explaing assignment of scalar variables in perl

    - Assigned using "="
    - Ex: $myVariable = 5;

    Summarize the siz arithmetic comparison operators

    <
    >
    ==
    <=
    >=
    !=

    Summarize the size string comparison operators

    eq
    ne
    lt
    le
    gt
    ge

    Explain the use of "if" "if-else" and "if-elsif-else"

    flow-control
    There are also unless conditional flow-control statements

    Identify the purpose of {} in an "if" statement

    Define the execution block of the if statement. Unlike C, the {} braces ARE REQUIRED

    List the conditions which evaluate as false

    0
    undef
    () -- arrays
    "" -- string
    EOF -- end of file
    "0"

    Identify the four types of loops in perl

    while
    until
    for
    foreach

    Interpret the syntax of a while loop

    while(condition)
    {
    CODE TO EXECUTE
    }

    Interpret the syntax of the foreach loop

    foreach $element(@arrayName)
    {
    CODE TO EXECUTE
    }

    In this case $element is a reference to a specific element of @arrayName. If you change the value of $element, the value will change in the array as well

    Explain the assignment of arrays in perl

    @array=("el1", "el2", "el3", 16, 12);
    - Elements need not be similar data types
    - Arrays can be assigned or read in scalar context (Ex: $myArray[4] = 2)
    - Special array $#arrayName give value of last index available in the array. Ex an array of size 5 will have its $#arrayName = 4
    - scalar(@arrayName) returns the size of the array

    What does $#arrayName return

    The value of the last index of the array (NOT the data stored in that array element)

    What does scalar(@arrayName) return

    The size of the array names @arrayName

    Explain the @ARGV array in perl

    A special system variable used to pass arguments to script
    - Ex: perl ./myScript.pl arg1 arg2
    --$ARGV[0] will be "arg1", $ARGV[1] will be "arg2"

    Identify the variable that provides the last index of an array

    $#arrayName

    Explain common array functions

    pop(@array)
    push(@array, $new Value)
    shift(@array)
    unshift(@array, $newValue)
    sort(@array)
    reverse(@array)

    pop(@array)

    Removes the last element from the array

    push(@array, $newValue)

    Adds a new element to end of the array with value $newValue

    shift(@array)

    Removes the first element of the array

    unshift(@array, $newValue)

    Add a new element to the from of the array with the value $newwValue

    reverse(@array)

    reverse the elements of the array

    sort(@array)

    Sort and array alphabetically

    Explain assignment of hash variables in perl (when oringally defining the hash)

    %hashname = (key1=>"value1", key2=>"value2", key3=>"Value3")

    Explain assignment of a hash variable for a single hash element

    $hashName{keyName}="Value to Add"

    Explain the %ENV hash array

    Stores information about the current users environment. You can print this from the command line using printenv

    Explain common hash functions

    keys(%hash)
    values(%hash)
    each(%hash)
    delete($hash{keyName})
    exists($hash{keyName})
    reverse(%hash)

    keys(%hash)

    returns all of the keys of the hash as an array

    values(%hash)

    returns all of the values of the hash as an array

    exists($hashName{keyName})

    does the hash key with "keyName" exists

    each(%hash)

    returns a two element ray of the next key value pair; resultArray[0] is the key resultArray[1] is the value

    delete($hashName{key})

    delete the hash entry with the key given

    reverse(%hashName)

    swap keys for values and values for keys. Will cause issues if there are multiple hash entries with the same value

    Define the open() statement in perl

    open(FILEHANDLE, file_mode, "filename.txt")
    - file mode is either ">", "<" or ">>"; write, read and append respectively

    List the three basic file access modes of the open() function

    > write
    >> append
    < read

    Explain how to read a line from a file handle

    $line=<FILEHANDLE>
    To get rid of the newline in $line, you could now chomp() (Ex: chomp($line);)

    Explain how to read an entire file into an array (one line per element)

    @entireFile=<FILEHANDLE>
    Again you could chomp this array to get rid of all the newlines (Ex chomp(@entireFile)

    Explain how to write to a filehandle

    print(FILEHANDLE "Data to output\n");

    Define the two primary methods of executing system commands in perl

    - system("command args")
    - `command args`

    Describe the system() function in perl

    - used to execute an external command
    -will output results of command to terminal
    - returns the exit status of the program that ran
    - use this for commands that you dont care about SAVING the output to a variable

    Describe the command substitution in perl

    - uses grave marks `command args`
    - returns the output of the command to the variable you specify
    - if $output = `command arg` the output is stored all in one variable (all lines seperated by \n)
    - if @output = `command arg` the output is stored with each line of the output as a different array element

    Define common string manipulation functions

    substr($string, $start, $numchars);
    length($string)
    lc($string)
    uc($string)
    chomp($string)
    chomp(@string)
    join(':", @string)
    split(/\s/, $string)
    lcfirst($string)
    ucfirst($string)

    chomp($string)

    remove trailing newline

    chomp(@string)

    remove trailing newline from each element in the array

    length($string)

    returns the length of the string including escape sequences

    uc($string)

    returns a copy of the string as all upper case

    lc($string)

    returns a copy of the string as all lower case

    ucfirst($string)

    returns a copy of the string with the first letter upper case

    lcfirst($string)

    returns a copy of the string with the first letter lower case

    split(/\s/, $string)

    split string into an array using spaces as delimeter

    join(':', @array)

    join the elements of the array seperating the elements with the ':' character

    substr($string, $startindex, $numchars)

    return the sub string starting at index $startindex and ending after $numchars chars in the string $string

    Two basic binding operators in regular expressions

    =~ Contains
    !~ Does not contain

    Regular Expression Quantifiers

    * - 0 or more characters
    + - 1 or more characters
    ? - 0 or 1 characters

    Regular Expression chararcter classes

    \w - alphanumeric word including underscor
    \d - digits 0-9
    \s any whitespace
    . - any character

    Please allow access to your computer’s microphone to use Voice Recording.

    Having trouble? Click here for help.

    We can’t access your microphone!

    Click the icon above to update your browser permissions above and try again

    Example:

    Reload the page to try again!

    Reload

    Press Cmd-0 to reset your zoom

    Press Ctrl-0 to reset your zoom

    It looks like your browser might be zoomed in or out. Your browser needs to be zoomed to a normal size to record audio.

    Please upgrade Flash or install Chrome
    to use Voice Recording.

    For more help, see our troubleshooting page.

    Your microphone is muted

    For help fixing this issue, see this FAQ.

    Star this term

    You can study starred terms together

    NEW! Voice Recording

    This is a Plus feature