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

  • How do you call a specific function from a package?

    package::function

    What's the variable name that includes all module include directory?

    @INC

    What is %INC?

    Whenever a module is loaded, it's inserted into %INC, and thus preventing duplicated loading.

    What's the default package name?

    main::

    What's Perl equivalent of 'break'?

    last

    How do you declare
    1) anonymous array
    2) anonymous hash

    $a = [1,2,3];
    $b = {1=>"a", 2=>"b", 3=>"c"};

    What does "bless" do?

    It associates a reference with a package.

    use vs. require

    1) 'use' is executed during the compile time, 'require' doesn't.
    2) 'use' calls 'import', which is defined in modules to affect the current namespace.

    How does OOP work in Perl?

    A module, named by 'package', is a class. It has a subroutine called "new", which calls "bless" between a hash containing member variables and the class name.

    Perl modules should have the extension of what?

    pm, not pl.

    What must be done for perl modules?

    Specify a return value: the last line should be "1"

    What does @ISA do?

    It indicates parent classes.

    What does "our" do?

    Make a variable visible in the entire file across packages.

    package bar;
    our $m = 5;
    package foo;
    print($m);

    What does "local" do?

    Temporarily assign a value to a global variable within a block.

    $a=3;
    sub printA { printf("$a\n"); }

    {
    local $a = 5;
    &printA; // 5
    }
    &printA; // 3

    exec vs. system

    The exec command stops the execution of the current process and starts the execution of the new process and does not return back to the stopped process. But the system command, holds the execution of the current process, forks a new process and continues with the execution of the command specified and returns back to the process on hold to continue execution

    How do you know how many times a substitution happened with =~ operator?

    $count = ($str =~ s/pattern/pattern/);

    How would you add two arrays?

    @sum = (@arr1, @arr2);

    Use 'each' to iterate hash kv-pairs

    while (my ($name, $length) = each %lengths) {
    ...
    }

    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