[22869] in Perl-Users-Digest
Perl-Users Digest, Issue: 5090 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 7 18:05:40 2003
Date: Sat, 7 Jun 2003 15:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 7 Jun 2003 Volume: 10 Number: 5090
Today's topics:
char to number conversion w/ a twist (MF)
Re: char to number conversion w/ a twist <bob@nowhere.com>
Re: char to number conversion w/ a twist <mbudash@sonic.net>
Re: char to number conversion w/ a twist <bwalton@rochester.rr.com>
Re: char to number conversion w/ a twist (MF)
Re: char to number conversion w/ a twist (MF)
Re: Converting numerical character references to Unicod <apollock11@hotmail.com>
Error when using File::Remote 1.16 <dayton@gecko.org>
Re: how to find no of elements in array/hash/array pass <bob@nowhere.com>
Re: how to find no of elements in array/hash/array pass <bob@nowhere.com>
Re: how to find no of elements in array/hash/array pass <me@verizon.invalid>
Re: how to find no of elements in array/hash/array pass <bob@nowhere.com>
Perl exam - fair or not? <>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 7 Jun 2003 11:17:27 -0700
From: mfabache@yahoo.com (MF)
Subject: char to number conversion w/ a twist
Message-Id: <2855726c.0306071017.1437594b@posting.google.com>
Can somebody point me in the right directon or help? I need to store
the following example chars in number format. However, each character
will have a n*.n[n][n][KMB] type format
Easier to explain what the input will be and what I would like to get
back:
Input/Output
24.0K/24000
24.2K/24200
24.21K/24210
3.1M/3100000
3.10M/3100000
3M/3000000
3.31M/3310000
2.245B/2245000000
2B/2000000000
2.0B/2000000000
etc.
Any ideas?
Thanks,
Michael
------------------------------
Date: Sat, 07 Jun 2003 13:45:29 -0500
From: bob <bob@nowhere.com>
Subject: Re: char to number conversion w/ a twist
Message-Id: <3ee232bd$1_1@127.0.0.1>
%mult = (
K=>1000,
M=>1000000,
B=>1000000000
);
$in =~ /([0-9\.]+)([KMB])/;
$out = $1 * $mult{$2};
On Sat, 07 Jun 2003 13:17:27 -0500, MF wrote:
> Can somebody point me in the right directon or help? I need to store
> the following example chars in number format. However, each character
> will have a n*.n[n][n][KMB] type format
>
> Easier to explain what the input will be and what I would like to get
> back:
>
> Input/Output
> 24.0K/24000
> 24.2K/24200
> 24.21K/24210
>
> 3.1M/3100000
> 3.10M/3100000
> 3M/3000000
> 3.31M/3310000
>
> 2.245B/2245000000
> 2B/2000000000
> 2.0B/2000000000
>
> etc.
>
> Any ideas?
>
> Thanks,
> Michael
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
------------------------------
Date: Sat, 07 Jun 2003 18:55:22 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: char to number conversion w/ a twist
Message-Id: <mbudash-284753.11552507062003@typhoon.sonic.net>
In article <2855726c.0306071017.1437594b@posting.google.com>,
mfabache@yahoo.com (MF) wrote:
> Can somebody point me in the right directon or help? I need to store
> the following example chars in number format. However, each character
> will have a n*.n[n][n][KMB] type format
>
> Easier to explain what the input will be and what I would like to get
> back:
>
> Input/Output
> 24.0K/24000
> 24.2K/24200
> 24.21K/24210
>
> 3.1M/3100000
> 3.10M/3100000
> 3M/3000000
> 3.31M/3310000
>
> 2.245B/2245000000
> 2B/2000000000
> 2.0B/2000000000
>
> etc.
>
> Any ideas?
>
> Thanks,
> Michael
one way:
my %mult = (
K => 1000,
M => 1000000,
B => 1000000000,
);
my @in = qw/
24.0K
24.2K
24.21K
3.1M
3.10M
3M
3.31M
2.245B
2B
2.0B
/;
for (@in) {
print "$_: ";
unless (/^(.+?)([KMB])$/) {
print "can't parse!";
}
else {
print ($1 * $mult{$2});
}
print "\n";
}
yields:
24.0K: 24000
24.2K: 24200
24.21K: 24210
3.1M: 3100000
3.10M: 3100000
3M: 3000000
3.31M: 3310000
2.245B: 2245000000
2B: 2000000000
2.0B: 2000000000
hth-
--
Michael Budash
------------------------------
Date: Sat, 07 Jun 2003 20:40:21 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: char to number conversion w/ a twist
Message-Id: <3EE24D12.3040709@rochester.rr.com>
MF wrote:
> Can somebody point me in the right directon or help? I need to store
> the following example chars in number format. However, each character
> will have a n*.n[n][n][KMB] type format
...
> Michael
s/(.*)([KMB])/$1*{K=>1e3,M=>1e6,B=>1e9}->{$2}/ei;
--
Bob Walton
------------------------------
Date: 7 Jun 2003 14:47:11 -0700
From: mfabache@yahoo.com (MF)
Subject: Re: char to number conversion w/ a twist
Message-Id: <2855726c.0306071347.391f4cb0@posting.google.com>
Michael Budash <mbudash@sonic.net> wrote in message news:<mbudash-284753.11552507062003@typhoon.sonic.net>...
> In article <2855726c.0306071017.1437594b@posting.google.com>,
> mfabache@yahoo.com (MF) wrote:
>
> > Can somebody point me in the right directon or help? I need to store
> > the following example chars in number format. However, each character
> > will have a n*.n[n][n][KMB] type format
> >
> > Easier to explain what the input will be and what I would like to get
> > back:
> >
> > Input/Output
> > 24.0K/24000
> > 24.2K/24200
> > 24.21K/24210
> >
> > 3.1M/3100000
> > 3.10M/3100000
> > 3M/3000000
> > 3.31M/3310000
> >
> > 2.245B/2245000000
> > 2B/2000000000
> > 2.0B/2000000000
> >
> > etc.
> >
> > Any ideas?
> >
> > Thanks,
> > Michael
>
> one way:
>
> my %mult = (
> K => 1000,
> M => 1000000,
> B => 1000000000,
> );
>
>
> my @in = qw/
> 24.0K
> 24.2K
> 24.21K
> 3.1M
> 3.10M
> 3M
> 3.31M
> 2.245B
> 2B
> 2.0B
> /;
>
> for (@in) {
> print "$_: ";
> unless (/^(.+?)([KMB])$/) {
> print "can't parse!";
> }
> else {
> print ($1 * $mult{$2});
> }
> print "\n";
> }
>
>
> yields:
>
> 24.0K: 24000
> 24.2K: 24200
> 24.21K: 24210
> 3.1M: 3100000
> 3.10M: 3100000
> 3M: 3000000
> 3.31M: 3310000
> 2.245B: 2245000000
> 2B: 2000000000
> 2.0B: 2000000000
>
> hth-
Excellent work Superfriends!
new to perl, this stuff is so powerful, yet so confusing. Thanks for
giving me a boost - problem sovled!
Thanks to all
------------------------------
Date: 7 Jun 2003 14:58:09 -0700
From: mfabache@yahoo.com (MF)
Subject: Re: char to number conversion w/ a twist
Message-Id: <2855726c.0306071358.63cd6b8f@posting.google.com>
Spoke to soon! ;)
I can do an indivual char/number conversion with the code previously
provided, but how can I use it to manipulate the following data?
Input:
32,18,27,172,483.0M,,6.23,,1,3,20.0K,116.0K
Desired Output:
32,18,27,172,483000000,,6.23,,1,3,20000,116000
Im trying to figure something out at the moment...
------------------------------
Date: Sat, 07 Jun 2003 11:15:15 -0700
From: Arvin Portlock <apollock11@hotmail.com>
Subject: Re: Converting numerical character references to Unicode
Message-Id: <bbta3m$t8v$1@agate.berkeley.edu>
Yup, that works, Thanks! For some reason I didn't think the binmode
thing was the way to do it in Perl 5.8. I tried a whole variety
of things using Unicode::String, too numerous to post here. Binmode
just seemed so perl 5.6. Now I know.
my $string = 'Α'; # Greek capital Alpha
my ($num) = $string =~ /&#x(\d{4});/;
my $char = chr(oct("0x$num"));
binmode STDOUT, ":utf8";
print "|\x{0391}|$char|\n";
|Α|Α|
>
> Code snippet:
>
> my $foo = chr(169);
> print "|\x{00A9}|$foo|\n";
>
> binmode STDOUT, ":utf8";
> print "|\x{00A9}|$foo|\n";
>
------------------------------
Date: Sat, 07 Jun 2003 21:16:48 GMT
From: "Dayton Jones" <dayton@gecko.org>
Subject: Error when using File::Remote 1.16
Message-Id: <4DsEa.35344$rO.3286550@newsread1.prod.itd.earthlink.net>
I'm writing a script using File::Remote and keep getting the following
error:
Host key verification failed.
lost connection
when I run my script.
Here is how I am using the module:
use File::Remote qw(:replace);
setrsh('/usr/bin/ssh');
setrcp('/usr/bin/scp');
settmp('/tmp');
If I ssh from command line there is no issue, and if I use
`ssh $server $command`;
in the script, it works fine too.
What is different about how Remote.pm utilized ssh? How can I correct this
issue? Thanks in advance for any help...
------------------------------
Date: Sat, 07 Jun 2003 13:15:20 -0500
From: bob <bob@nowhere.com>
Subject: Re: how to find no of elements in array/hash/array passed to subroutine without reference?
Message-Id: <3ee22bac$1_1@127.0.0.1>
Almost forget the original question:
If you insist on not passing references AND you know that you are always
passing an array, a hash and an array, in thatb order, then pass the
lengths first, eg. something like (NOT TESTED):
# NOT TESTED!
$L1 = scalar @arr1;
$L2 = 2 * scalar keys %hash;
$L3 = scalar @arr2;
# scalar functions above probably unneeded due to context.
# NOT TESTED!
my subroutine( $L1, $L2, $L3, @arr1, %hash, @arr2) {
my @a1 = @_[0..$L1-1];
my %hash = @_[$L1..$L2-1];
my @a2 = @_[$L2..$#_];
# knock yourself out.
# if original arrays and hash containd no references, # all changes are
# local
}
__END__
but this seriously sucks. it breaks easily. Use Storable to copy if
needed and pass references.
replies to bob AT bob-n DOT com
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
------------------------------
Date: Sat, 07 Jun 2003 13:18:27 -0500
From: bob <bob@nowhere.com>
Subject: Re: how to find no of elements in array/hash/array passed to subroutine without reference?
Message-Id: <3ee22c66$1_1@127.0.0.1>
Told you this wasn't tested, this should be
mysubroutine( $L1, $L2, $L3, @arr1, %hash, @arr2);
sub mysubroutine
{
my @a1 = @_[0..$L1-1];
my %hash = @_[$L1..$L2-1];
my @a2 = @_[$L2..$#_];
# knock yourself out.
# if original arrays and hash containd no references, # all changes are
# local
}
On Sat, 07 Jun 2003 13:15:20 -0500, bob wrote:
> my subroutine( $L1, $L2, $L3, @arr1, %hash, @arr2) {
> my @a1 = @_[0..$L1-1];
> my %hash = @_[$L1..$L2-1];
> my @a2 = @_[$L2..$#_];
>
> # knock yourself out.
> # if original arrays and hash containd no references, # all changes are
> # local
> }
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
------------------------------
Date: Sat, 07 Jun 2003 18:32:03 GMT
From: "dw" <me@verizon.invalid>
Subject: Re: how to find no of elements in array/hash/array passed to subroutine without reference?
Message-Id: <DcqEa.43938$ca5.14983@nwrdny02.gnilink.net>
"bob" <bob@nowhere.com> wrote in message news:3ee22c66$1_1@127.0.0.1...
> mysubroutine( $L1, $L2, $L3, @arr1, %hash, @arr2);
>
> sub mysubroutine
> {
don't you also need something like
my $L1 = shift;
my $L2 = shift;
my $L3 = shift;
to get those first few items out of @_
> my @a1 = @_[0..$L1-1];
> my %hash = @_[$L1..$L2-1];
> my @a2 = @_[$L2..$#_];
>
> # knock yourself out.
> # if original arrays and hash containd no references, # all changes are
> # local
> }
>
>
------------------------------
Date: Sat, 07 Jun 2003 13:37:28 -0500
From: bob <bob@nowhere.com>
Subject: Re: how to find no of elements in array/hash/array passed to subroutine without reference?
Message-Id: <3ee230db$1_1@127.0.0.1>
Damn straight. Since I NEVER plan on doing anything like this myself, I
didn't test it, as I noted. But you are absolutely correct.
On Sat, 07 Jun 2003 13:32:03 -0500, dw wrote:
> don't you also need something like
> my $L1 = shift;
> my $L2 = shift;
> my $L3 = shift;
> to get those first few items out of @_
>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
------------------------------
Date: Sat, 07 Jun 2003 13:45:24 -0700
From: anon <>
Subject: Perl exam - fair or not?
Message-Id: <6lj4evo1lk8l782dlgvocoba1pap35i2oj@4ax.com>
A friend of mine took a Perl class in college and was given this exam.
I was really annoyed and confused by some of the questions - some of
them aren't about Perl, and some seem to check attendance rather than
understanding - you'd never find these questions answered (or even
asked) outside of class, even if you've been doing Perl programming
for years.
It seems a bad side effect of "there's more than one way to do it" is
that you may be able to do it, but you probably don't know all the
ways to do it, so if asked about some of them you'll probably have no
idea.
Anyway, here are the 50 questions and their answers. The time limit
was, I believe, 2 hours and students were allowed to use any reference
source, online or offline, or even the perl interpreter.
1. Which of the following are advantages of Unicode over ASCII?
(a) Faster than ASCII.
(b) Unicode has sufficient byte capacity to accommodate all the
characters of the all the languages in the world.
(c) Unicode is faster than ASCII but harder to use for Asian
languages.
(d) All Unicode characters can be accessed without the need for
escape sequences or control codes.
2. Metacharacters lose their special meaning if preceded with a
backslash (\) (true/false).
3. Which of the following can be represented by metacharacters?
(a) Whitespace Characters
(b) British Currency
(c) Repeated Characters
(d) Canadian Currency
4. Which modifier is needed so that the dot (.) metacharacter will
match a newline character. (Choose only ONE)
(a) r Modifier
(b) s Modifier
(c) t Modifier
(d) There is no modifier that will perform this function.
5. What special meanings does the caret (^) character have in regular
expressions?
(a) When it is the first character outside a character class ([]), it
represents a "not" in the set.
(b) When it is the first character inside a character class ([]), it
represents a "not" in the set.
(c) The ^ character has no special meaning unless it is preceded by a
backslash (\).
(d) Represents a beginning of line anchor.
6. What is true about POSIX character classes? (Choose only ONE)
(a) You must have Perl 5.02+ to support POSIX character classes.
(b) POSIX character classes are dependant on ASCII character
encoding.
(c) You can negate one of the characters in a POSIX character class.
(d) POSIX character classes are not supported on non-standard
keyboards.
7. What's the best way to make a regular _expression case insensitive?
(Choose only ONE)
(a) Use the lc() function on your string before you pass it to the
regular _expression.
(b) Use a translate _expression to make your string lowercase
(tr/A-Z/a-z/).
(c) Use the bless() function to make subsequent matches case
insensitive.
(d) Use the /i modifier.
8. What is true about the tr function? (Choose TWO)
(a) tr returns the number of words matched.
(b) It is very effective when used in combination with
metacharacters.
(c) It is similar to the UNIX tr command.
(d) It is exactly the same as the y function.
9. In order, which repetition metacharacters are used to represent, 0
or 1 occurrences, 0 or more occurrences, and 1 or more occurrences of
a pattern. (Choose only ONE)
(a) ?, *, +
(b) *, ?, +
(c) *, +, ?
(d) ?, +, *
10. What is true about the m modifier.
(a) Used to control the behavior of the $, \A, and \Z metacharacters.
(b) Used to control the behavior of the ^ (anchor), $, and \Z
metacharacters.
(c) Used to control the behavior of the ^ (anchor), $, and \A
metacharacters.
(d) Used to control the behavior of the ^ (anchor), \A, and \Z
metacharacters.
11. When opening text files on Win32 platforms, the \n (newline) is
translated into \r\n (return and newline character) when read from
disk (true/false).
12. Which of the following is true about the open function?
(a) Text files can be opened the same way regardless of the platform.
(b) Binary files can be opened the same way regardless of the
platform.
(c) Returns an undefined value if successful and a non zero result if
it fails.
(d) Returns a non zero result if successful and undefined value if it
fails.
13. What is true about the special $! variable.
(a) Contains a numeric system error (if evaluated in numeric context)
when you are unable to successfully open a file or execute a system
utility.
(b) Contains a system error message (if evaluated in string context)
when you are unable to successfully open a file or execute a system
utility.
(c) When used with the else statement is very useful for detecting a
problem with a file handle before continuing with the execution of a
script.
(d) Only works on the Win32 platform.
14. When a file is opened for appending, it will be created if it does
not exist, and if it does exist, it will be overwritten (true/false).
15. What is true about the following statement:
select(STDOUT);
(a) Selects STDOUT only for FILE/IO write requests.
(b) Sets the default output to the STDOUT filehandle and returns the
previously selected filehandle.
(c) Selects STDOUT only for FILE/IO read requests.
(d) Selects STDOUT only for FILE/IO print requests.
16. What is true about file locking with flock?
(a) Takes 2 arguments, the filename as a string, and a file lock
operation.
(b) May not work if the file is being accessed from a networked file
system.
(c) File locking only works on non-binary files.
(d) Requires write permission for a shared lock and read permission
on a exclusive lock.
17. Which function allows you read a certain byte position within a
file? (Choose only ONE)
(a) tell
(b) find
(c) raccess
(d) seek
18. How can you prevent the "die" function from printing extra
information beyond the string in its argument list? (Choose only ONE)
(a) There is no way.
(b) The implementation depends on your platform.
(c) By including the newline "\n" character at the end of the
argument.
(d) By using /np modifier in the die function print argument.
19. What is true about the ARGV array?
(a) Identical to the ARGV array in C.
(b) ARGV[0] holds the name of the program.
(c) When no arguments are given to a program, the array evaluates to
FALSE.
(d) Its array index starts at 1.
20. Perl includes a number of file test operators including ones which
can ascertain if a file is binary and/or readable and including ones
which can determine the file's access permissions (true/false).
21. What are the differences between subroutines and functions in
Perl?
(a) Functions return a value and are declared with the func keyword.
(b) A function is simply a subroutine that happens to have an
explicit return value.
(c) Subroutines are faster than functions since they have to support
fewer features than functions.
(d) You can prototype a function but not a subroutine.
22. Which of the following are valid methods of calling a subroutine
named "testsub" (without a forward reference)?
(a) &testsub;
(b) testsub();
(c) %testsub();
(d) testsub;
23. What is the return value of a subroutine? (Choose only ONE)
(a) Subroutines don't have return values, only functions do.
(b) The value of the last _expression evaluated (either scalar or an
array).
(c) 1 on success, 0 on failure.
(d) 0 on success, 1 on failure.
24. A subroutine that has not been explicitly declared is declared at
the same time that it is defined (true/false).
25. Which variable(s) hold the arguments passed to a subroutine?
(a) $_
(b) @ARGV
(c) $ARGV
(d) @_
26. The default in Perl is call-by-value when arrays or scalars are
passed to a function or subroutine (true/false).
27. Which of the following are differences between call-by-value and
call-by-reference?
(a) In a call-by-reference, the original variable is untouched.
(b) In a call-by-value, the original variable is untouched.
(c) @_ is used for a call-by-reference, but $_ is used for a
call-by-value.
(d) @ARGV is used for a call by reference, but $ARGV is used for a
call-by-value.
28. Which are valid methods of turning on call-by-value?
(a) Using the local function.
(b) Using the my function.
(c) Using the values function.
(d) Using the & symbol to call the subroutine.
29. The subs function allows you to override built-in Perl functions
(true/false).
30. Which of the following are true about lexically scoped variables?
(a) Only supported in Perl 5.6+.
(b) Visible from the point of declaration to the end of the innermost
enclosing block.
(c) local ($variables) are lexically scoped.
(d) my ($variables) are lexically scoped.
31. In the following code snippet:
$FirstName = "Robert";
$LastName = "FirstName";
print "${$LastName}";
What is the argument in the print statement? (Choose only ONE)
(a) A hard reference.
(b) A symbolic reference.
(c) A pointer.
(d) A hard pointer.
32. Which of the following de-references an anonymous array assigned
to an array reference named $arrTest and prints its first element?
(a) print $arrTest->[0];
(b) print @{$arrTest}[0];
(c) print ${$arrTest}[0];
(d) print $$arrTest[0];
33. What function can I use to find out which type of "thing" (Eg.
reference, scalar, array, hash, code, glob) a reference is
referencing? (Choose only ONE)
(a) pointer function
(b) bless function
(c) ref function
(d) values function
34. The only way to pass a filehandle directly to a subroutine is by
reference (true/false).
35. An anonymous subroutine is created by using the keyword sub and
prefixing the subroutine name with string "anon_" (true/false).
36. You can use references to create:
(a) a filehandle of filehandles
(b) a hash of hashes.
(c) multidimensional arrays.
(d) an array of hashes.
37. Which of the following creates a hard reference to a hash. (Choose
only ONE)
(a) $test_ref = %test_hash;
(b) $test_ref = %{test_hash};
(c) $test_ref = $%test_hash;
(d) $test_ref = \%test_hash;
38. What is the following statement?
*myalias=*myvar;
(a) a typeglob.
(b) a hard reference.
(c) a symbolic reference.
(d) a hard pointer.
39. What will you see if you print the value of a hard reference?
(Choose only ONE)
(a) A random location in memory.
(b) The address of the thing being referenced.
(c) 0.
(d) The variable type followed by 0's.
40. When is the special BEGIN subroutine executed? (Choose only ONE)
(a) Immediately after Main.
(b) Immediately where it is located before the rest of the file is
parsed.
(c) Immediately after the file is parsed.
(d) Right before END.
41. A class is a package that contains data and methods (true/false).
42. How is an object created in Perl? (Choose only ONE)
(a) By using the special subroutine new to bless a new instance of a
package.
(b) By creating a hard reference and then blessing the reference into
a package.
(c) By using the special @EXPORT array.
(d) By blessing a reference the main subroutine of the calling
application
43. In which order does Perl search for a subroutine (method) that
cannot be found in the current package? (Choose only ONE)
(a) AUTOLOAD subroutine, @ISA, UNIVERSAL package
(b) AUTOLOAD subroutine, @ISA, UNIVERSAL package
(c) @ISA, AUTOLOAD subroutine, UNIVERSAL package
(d) @ISA, UNIVERSAL package, AUTOLOAD subroutine
44. What are the three methods that all classes inherit? (Choose only
ONE)
(a) can, VER, ina
(b) can, VERSION, ina
(c) isa, can, VER
(d) isa, can, VERSION
45. When a class inherits methods from more than one base or child
class, it is called multiple inheritance (true/false).
46. What's the difference between static and virtual methods?
(a) Static methods expect a class name as the first argument, and
virtual methods expect an object reference as the first argument.
(b) Virtual methods expect a class name as the first argument, and
static methods expect an object reference as the first argument.
(c) Static methods are used to create a object or act on a group of
objects, virtual methods are used to control the way the object's data
is assigned, modified and retrieved.
(d) Virtual methods are used to create a object or act on a group of
objects, static methods are used to control the way the object's data
is assigned, modified and retrieved.
47. Which of the following is true about constructors in Perl?
(a) Used to create and initialize an object into a class.
(b) The constructor method must be named "new".
(c) The constructor method is an instance method.
(d) The constructor method is a class method.
48. If you needed every new instance of a class to be initialized with
a set of 20 parameters retrieved from your driver program, what would
be the best method? (Choose only ONE)
(a) Pass the parameters as a list to the constructor.
(b) Pass the parameters as named parameters to the constructor.
(c) Create a method called "initialize" to get the parameters.
(d) Create a method called "init" to get the parameters.
49. What is true about the "::" and "->" notations when using
polymorphism, dynamic binding and inheritance.
(a) Both are allowed.
(b) -> is allowed, and :: is not.
(c) :: is more flexible and less problematic than ->.
(d) -> is more flexible and less problematic than ::.
50. You can define a DESTROY method in a program to get control of an
object just before it goes away (true/false).
The correct answers:
---------
1. b d
---------
2. true
---------
3. a c
---------
4. b
---------
5. b d
---------
6. c
---------
7. d
---------
8. c d
---------
9. a
---------
10. b d
---------
11. false
---------
12. a d
---------
13. a b
---------
14. false
---------
15. b
---------
16. b
---------
17. d
---------
18. c
---------
19. c
---------
20. true
---------
21. b
---------
22. a b
---------
23. b
---------
24. true
---------
25. d
---------
26. false
---------
27. b
---------
28. a b
---------
29. true
---------
30. b d
---------
31. b
---------
32. a b c d
---------
33. c
---------
34. true
---------
35. false
---------
36. b c d
---------
37. d
---------
38. a c
---------
39. b
---------
40. b
---------
41. true
---------
42. b
---------
43. c
---------
44. d
---------
45. false
---------
46. a c
---------
47. a d
---------
48. b
---------
49. a d
---------
50. true
---------
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 5090
***************************************