Vous êtes sur la page 1sur 8

See the following questions. It will improve your PERL knowledge.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Question 1
How do you perform a forward declaration of a subroutine performed?
Choice 1
forward sub name;
Choice 2
sub name;
Choice 3
forward name;
Choice 4
sub name {};
Choice 5
sub {};
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Question 2
Sample Code
Code:
INSERT INTO names VALUES ('John')
How do you use the DBI module to execute the above SQL statement? Assume $dbh is the return
value from DBI->connect.
Choice 1
my $statement = $dbh->execute("INSERT INTO names VALUES ('John')");
Choice 2
my $statement = $dbh->sql("INSERT INTO names VALUES ('John')");
$statement->execute;
Go4Expert > Articles > Programming > Perl > Multiple Choice Questions in PERL
Multiple Choice Questions in PERL
Contributed by ungalnanban On 19th February, 2010
This is an article on Multiple Choice Questions in PERL in Perl.
Choice 3
my $statement = $dbh->prepare("INSERT INTO names VALUES ('John')");
$statement->execute;
Choice 4
my $statement = $dbh->run("INSERT INTO names VALUES ('John')");
Choice 5
my $statement = $dbh->insert("INSERT INTO names VALUES ('John')");
$statement->finish;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Question 3
Which regular expression deletes all tags specified as text enclosed by "<" and ">" from a
document stored in a string, but deletes nothing else.
Choice 1
$string =~ s/<*&>//g;
Choice 2
$string =~ s/<\S*>//g;
Choice 3
$string =~ s/<\s*>//g;
Choice 4
$string =~ s/<.*?>//g;
Choice 5
$string =~ s/<.*>//g;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Question 4
Which one of the following completely defines scalars?
Choice 1
A number, an array, or a associative array
Choice 2
A single string, number, or reference
Choice 3
A string, a lexical array, or a numeric value
Choice 4
A pointer, a stack, or a heap
Choice 5
An int, float, double, or char
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Question 5
Sample Code
Code:
@values = ( "value1", "value2", ("value3", "value4") );
How does Perl store the nested list shown above?
Choice 1
The list is stored as a hierarchical list.
Choice 2
The list is stored as a hash with the offsets as keys to the hash.
Choice 3
The list is flattened by removing all internal bracketing.
Choice 4
The list stores two values, "value1" and "value2", plus a pointer to
the internal list.
Choice 5
The list stores two values, "value1" and "value2", plus two pointers
to "value3" and "value4."
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Question 6
Sample Code
Code:
printSorted(\@list,dir => 'asc', type => 'numerical');
Many functions in perl take option lists such as the ones in the above code sample. Given the
information shown above, what does the line in the printSorted subroutine that retrieves the
parameters probably look like?
Choice 1
my (@data,$options) = @_;
Choice 2
my ($data,%options) = @_;
Choice 3
my ($data,$option1,$option2) = @_;
Choice 4
my ($data,$options) = @_;
Choice 5
my (@data,@options) = @_;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Question 7
Which one of the following regexes matches between 1 to 4 ab's followed by a tab and an integer
number?
Choice 1
(ab)+{4}\t\d*
Choice 2
ab[ababab]\t[0-9]
Choice 3
{ab,4}\t\d+
Choice 4
(ab)?[1-4]\t[0-9]*
Choice 5
(ab){1,4}\t\d+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Question 8
Sample Code
Code 1:
Code:
my @lines = grep /^hi/, @allLines;
Code 2:
Code:
my @lines = (); foreach (@allLines) { push (@lines,$_) if (/^hi/); }
What is the difference between the two snippets (Code 1 and Code 2) above?
Choice 1
In code 1, the operation occurs in one command; code 2 iterates each
element in the array for matches.
Choice 2
In code 1, the elements of @lines are the indexes in @allLines, in
which matches were found.
Choice 3
In code 1, the elements of "@lines" begin with the index in
"@allLines", in which the match was found.
Choice 4
In code 2, no matches are found.
Choice 5
In code 1, "@lines" may not necessarily be in the same order; the
original lines appear in "@allLines".
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Question 9
Which conditional statement is equivalent to "if (!<condition>)"?
Choice 1
unless (<condition>)
Choice 2
failure (<condition>)
Choice 3
fails (<condition>)
Choice 4
ifn (<condition>)
Choice 5
require (<condition>)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Question 10
Problem
You need to check to see what version of Perl a module you have written is running. You know that
Perl versions earlier than 5.005 do not work properly with your module.
Given the problem shown above, how do you check that the version of Perl is new enough?
Choice 1
Using "$|>=5.005"
Choice 2
Using "$]>=5.005"
Choice 3
Using "%INC{VERSION}>=5.005"
Choice 4
Using "$PERLVER>=5.005"
Choice 5
Using "$$>=5.005"
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
shabbir
Go4Expert Founder
#2
rahuliet2008
Newbie Member
#3
0
0
mishrabhishek4 like this
Related Articles
100 Multiple choice questions in C, by coderzone in C
HTML Beginners question, by coderzone in Web Design, HTML And CSS Tutorials
2Mar2010,20:35
Nomination for Article of the month - Feb 2010 started. Nominate this article.
22Nov2010,14:36
fr where i get the answ
Article Tools
Already a member?
User Name: User Name Save
Password Log in
Forgot Username/Password?
Not a member yet?
Create Your Free Account Now.
Search Go4Expert
Search
Advance Search
Latest Forum Topics
Perl login problem
Under Perl
Perl post process action
Under Perl
Rate this Article Printable Version
Compile Error in Perl
Under Perl
Need help with a script for a project
Under Perl
perl script to get url from file
Under Perl
Find Us On Facebook
Latest Articles
Clean User Input HTML using HTML::Scrubber
Under Perl
Introduction to JSON in Perl
Under Perl
Simple Web Crawler in Perl
Under Perl
Twitter Controlled RAT (Mobile accessible)
Under Perl
Multiple Choice Questions in PERL
Under Perl
Contact Us - Go4Expert.com - Programming and Web Development Forum - Sitemap - Forum - Privacy Statement
- Top
User Contribution Licensed Under Creative Commons with Attribution Required. Site Design and Logo Copyright
Go4Expert 2004 - 2014.

Vous aimerez peut-être aussi