freelanceprogrammers.org Forum Index » Perl

Doubts

View user's profile Post To page top
perl_sathiya Posted: Thu Dec 21, 2006 4:04 pm


Joined: 21 Dec 2006

Posts: 1
Doubts
hi,
I am new to this group...... i preferred to join here for getting
answers for my doubts, ....


#! /usr/local/bin/perl -Tw

sub foo {
my $data = shift;
if ($data =~ /^([-w.]*)$/) {
return $1;
}
return $data;
}

my $line = <STDIN>;
$line = foo($line);

Question When is code similar to the above code used in a perl program?
Choice 1
When preparing a function that will eventually check data for
specific criteria
Choice 2
When running setuid perl scripts that must securely use user-supplied
data
Choice 3
When any string data must contain at least one character
Choice 4
When wanting to have a function return a string form of a parameter
Choice 5
When most data is required as a scalar

------------------------------------------------------


while (my ($key,$value) = each(%main::)) {
local(*gl) = $value;
print "$key - $gl
";
}
Question What does the above sample code print?
Choice 1
The names and scalar contents of all variables in the main namespace
Choice 2
A list of all packages contained underneath the main namespace
Choice 3
The current script indexed by line numbers
Choice 4
A list of all globs contained in the main namespace
Choice 5
The names and definitions of all subroutines in the main namespace
Reply with quote
Send private message
View user's profile Post To page top
merlynstoneh... Posted: Thu Dec 21, 2006 10:15 pm


Joined: 21 May 2004

Posts: 44
Doubts
>>>>> "perl" == perl sathiya <perl_sathiya@...> writes:

perl> hi,
perl> I am new to this group...... i preferred to join here for getting
perl> answers for my doubts, ....

More like *homework*.

Please don`t post homework questions here.

And please don`t *answer* homework questions here... imagine if this guy
goes on to get a degree having cheated his way through, then writes
the code for the banking web app that you need to use and it`s buggy
because he never learned how to code properly.

Ugh.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help