a) What is the differences between the \'chop\' and \'chomp\' Perl statements? b
ID: 3846489 • Letter: A
Question
a) What is the differences between the 'chop' and 'chomp' Perl statements? b) See the following statement. my ($last, $first, $email) = split /s+/, $student; Assume $student contains the string "Alpaugh, Weldon s0396012@monmouth.edu" What Perl data type does the above 'split' function return? (select one) (1) regular expression (2) list (3) hash (4) string c) (Select one answer below.) The "s+" above is called a (1) escape sequence (2) regular expression (3) delimiter (4) both (2) and (3) d) If "s+" is a regular expression, which of the following strings would contain a match for s+ ? (Select all that apply. Ignore all characters before "Alpaugh" and after ".edu".) (1) Alpaugh, Weldon, s0396012@monmouth.edu (2) Alpaugh,Weldon,s0396012@monmouth.edu (3) Alpaugh, Weldon, s0396012@monmouth.edu (4) Alpaugh, Weldon,s0396012@monmouth.edu e) As a result of the above 'split' statement in part b), the variable $last will contain "Alpaugh,". How could the 'split' statement be changed to avoid including a comma in $last?
Explanation / Answer
a)chop function removes the last character of a string and returns that. This operation is performed on each one of set of orguments and the last character chopped is returned.
chomp an alternative to the chop().But it removes characters at the end of strings based onthe $INPUT_LINE_SEPARATOR ($/).
The main difference is that Chomp() ONLY removes new line characters that are specified in $/), but Chop() removes end of the string.
b) (4)String.
c)(2) regular expression
d) d) If "s+" is a regular expression, which of the following strings
would contain a match for s+ ? (Select all that apply. Ignore all
characters before "Alpaugh" and after ".edu".)
Ans: (2) Alpaugh,Weldon,s0396012@monmouth.edu
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.