Home
Subjects
Textbook solutions
Create
Study sets, textbooks, questions
Log in
Sign up
Upgrade to remove ads
Only $35.99/year
COMP 206 - Perl
STUDY
Flashcards
Learn
Write
Spell
Test
PLAY
Match
Gravity
Terms in this set (51)
$ID = VALUE
Used to initiate Scalar values
%ID = VALUE
Used to initiate hash values
@ID = VALUE
Used to initiate array values
$a+$b, where a=1, b=2
3
$a.$b, where a=1, b=2
12
$a x 2, where a=hello
hellohello
*only works on strings!
$x = shift(@letters), where @letters = ('a', 'b', 'c')
$x = a
Shift removes left-est letter from array and pop onto new value.
chomp($letters), where $letters = ('abh\n')
@letters = abh.
Specifically removes \n new lines
"chomp $s" vs. "chomp ($s)"
no difference/error, in perl you don't need brackets.
'x=$x' v.s. "x=$x"
'x=$x' --> x=$x (literal meaning)
"x=$x" --> x=5 (evaluated)
q(it's value is $s) v.s. qq(it's value is $s)
q() = it's value is $s (literal)
qq() = it's value is 5 (evaluated)
$x=<STDIN>
Syntax for Perl Input.
E.g. chomp($x=<>) OR chomp($x=<STDIN>)
What is the first line in a PERL script?
Shebang line
E.g. #!/usr/bin/perl -wT
How to comment in PERL?
#comment
How to run PERL programs?
perl C:\perl_test\testing.pl
$x=pop(@days)
pops the last element in @days into x
$x=shift(@days)
pops the first element into @days into x
push(@days, 'END')
Adds 'END' to the end of the array
E.g. monday, tuesday..., END.
unshift(@days, 'FRONT')
Adds 'FRONT' to the front of the array
E.g. FRONT, monday, tuesday...
UNLESS(COND){}
Perl while loop, while condition false
UNTIL(COND){}
Perl while loop, loops until condition is true
NEXT;
same thing as 'continue' in C
LAST;
same thing as 'break' in C
FOREACH(){}
loops through each element in array
Perl -c program.pl
Show syntax error in PERL program when executing
Perl -w program.pl
Show warnings in PERL programs when executing
my($var=5)
Restricting var to only exist in the subroutine
$$x or @$x
pointer to scalar x or array x
print "In this array: Parms = @_";
prints out:
In this array: Var1 = $var1 Var2=$var2...
for ($_[0]..$_[3])
For loop, from [0]th element to [3]th element
$arr."X"
adds X to the end of array
local($var=5)
variable exists in ALL subroutines
if (/Bob/)
Regex, If 'Bob' is in the string, then TRUE.
if (/[<A,]/)
if <, A, or ',' are in the string, then TRUE.
// = regex expression
[] = regex meaning OR, so anything in the bracket.
if (/[A-Z]/) v.s. if (/[A-Z-]/) v.s. if (/[^A-Z]/)
if (/[A-Z]/) = if any cap letter from A-Z are in the string
if (/[A-Z]/) = if any cap letter from A-Z OR '-' are in the string.
if (/[^A-Z]/) = true ONLY if no cap letter from A-Z are in string.
if(/\d/)
regex shortcut, if any digits 0-9 are in the string
if(/\D/)
regex shortcut, true if NO digits (0-9) are in the string
if(/\w/)
regex shortcut, true if any letters are in the string
if(/\W/)
regex shortcut, true if NO letters are in the string
if(/\s/)
regex shortcut, true if there are white spaces (or \r\t\n\f) are in the string
if(/\S/)
regex shortcut, true if NO white spaces are in the string
/[A-Z]"\s/
regex, looking for any CAP letter followed by " and a white space.
E.g. X"
/a{3}b/
regex, looking for aaab
/a{1, 3}b/
regex, looking for...
ab, aab, or aaab
/a{1, }b/
regex, looking for anything like
ab, aab, aaab, aaaab...
/(ab){3}/
regex, looking for
ababab
/*a/
regex, if there are any a's, equaled to {0, }
none, a, aa, aaa, aaaa...
/+a/
regex, if there are any a's, eq to {1, }
a, aa, aaa, aaaa, aaaaa...
/?a/
regex, if there is an 'a'. Eq, to {0,1}
a
/^ABC/
If ABC is at
beginning
of string
/ABC$/
If ABC is at
end
of string
Sets with similar terms
Computer Programming
48 terms
7.11: If you Plan to continue in computer
23 terms
7.2: Accessing Array Elements
15 terms
Chapter 7 and 8 Programming 1 test 3
62 terms
Sets found in the same folder
Bioinfo 6: PERL
48 terms
Perl Syntax
21 terms
Perl Terms and Definitions
36 terms
CHAPTER 10: Protein Sequence Databases A…
5 terms
Other sets by this creator
UX Interview Questions
13 terms
Final (5 lectures)
185 terms
Midterm 2
112 terms
Drug History
42 terms
Verified questions
COMPUTER SCIENCE
Assume that you have a page-reference string for a process with m frames (initially all empty). The page-reference string has length p, and n distinct page numbers occur in it. Answer these questions for any page-replacement algorithms: a. What is a lower bound on the number of page faults? b. What is an upper bound on the number of page faults?
COMPUTER SCIENCE
'''Enter the size:9 # | 1 2 3 4 5 6 7 8 9 ---------------------------------------- 1 | 1 2 3 4 5 6 7 8 9 2 | 2 4 6 8 10 12 14 16 18 3 | 3 6 9 12 15 18 21 24 27 4 | 4 8 x x x x x x x 5 | 5 10 x x x x x x x 6 | 6 12 x x x x x x x 7 | 7 14 x x x x x x x 8 | 8 16 x x x x x x x 9 | 9 18 x x x x x x 81''' Write a program in python to display a multiplication table as shown above. Use Loops to print this table. It should be exactly as shown above, with "X" as shown. Take a screenshot of the script and the output Submit the script and the screenshot as a single pdf file.
COMPUTER SCIENCE
Suppose that the splits at every level of quicksort are in the proportion 1 - α to α, where 0 < α ≤ 1/2 is a constant. Show that the minimum depth of a leaf in the recursion tree is approximately - lg n/lg α and the maximum depth is approximately - lg n/ lg(1 - α). (Don’t worry about integer round-off.)
COMPUTER SCIENCE
True or false? Some library functions are built into the Python interpreter.
Other Quizlet sets
ANG ORTOGRAPIYANG PAMBANSA
25 terms
Escola sem partido
17 terms
HRTM 450: CHP 9
42 terms
Mass Media Midterm Questions
14 terms