[23881] in Perl-Users-Digest
Perl-Users Digest, Issue: 6084 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 5 14:05:47 2004
Date: Thu, 5 Feb 2004 11:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 5 Feb 2004 Volume: 10 Number: 6084
Today's topics:
Re: Arrays Of Arrays: Is it an Array or Scalar? <jill_krugman@yahoo.com>
Re: Arrays Of Arrays: Is it an Array or Scalar? <Graham.letterT.Wood@oracle.com>
Re: Arrays Of Arrays: Is it an Array or Scalar? <jgibson@mail.arc.nasa.gov>
Re: Arrays Of Arrays: Is it an Array or Scalar? <hal@thresholddigital.com>
Re: Copy Constructor Craziness (Unknown Poster)
Re: Docs comprehensibility <noreply@gunnar.cc>
Re: Docs comprehensibility <noreply@gunnar.cc>
executing from command line <aktanaktas@earthlink.net>
Re: executing from command line <1usa@llenroc.ude>
Re: executing from command line <dwall@fastmail.fm>
Re: executing from command line <dwall@fastmail.fm>
Re: executing from command line <syscjm@gwu.edu>
Re: executing from command line <nobull@mail.com>
Re: executing from command line <jurgenex@hotmail.com>
Re: Getting STDERR from forked child processes? <nobull@mail.com>
How to execute a command line in Perlscript (Eric SALGON)
Re: How to execute a command line in Perlscript <ceo@nospan.on.net>
Re: How to execute a command line in Perlscript <ceo@nospan.on.net>
Re: Perl data types <emschwar@pobox.com>
Re: Perl data types (Malcolm Dew-Jones)
Re: Perl For Amateur Computer Programmers (G Klinedinst)
Re: Perl For Amateur Computer Programmers <ddunham@redwood.taos.com>
Re: problem with "our" <spamtrap@dot-app.org>
Re: RDBMS to hold Perl objects? (Randal L. Schwartz)
Re: RDBMS to hold Perl objects? <jill_krugman@yahoo.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 5 Feb 2004 16:22:27 +0000 (UTC)
From: J Krugman <jill_krugman@yahoo.com>
Subject: Re: Arrays Of Arrays: Is it an Array or Scalar?
Message-Id: <bvtqk3$efj$1@reader2.panix.com>
In <AKtUb.185396$nt4.786330@attbi_s51> Hal Vaughan <hal@thresholddigital.com> writes:
>I have a function that I'm using to perform operations on strings in an
>array. There are times where I'd like to have this function work on arrays
>of arrays. Is there a simple way to tell if the value of an element in an
>array is a scalar, or is, instead, a reference to another array?
>I know I can use a regex to see if the string matches the pattern for an
>array reference, but is there a more "elegant" and easier way to do it?
>(And, while I'm at it, is there a way to check for a hash as well? I'd
>think they'd both be done the same way.)
perldoc -f ref
for my $elem (@array) {
if (my $r = ref $elem) {
if ($r eq 'ARRAY') {
# process arrayref
}
elsif ($r eq 'HASH') {
# process hashref
}
else {
# deal with non-array, non-hash ref
}
}
}
------------------------------
Date: Thu, 05 Feb 2004 16:30:16 +0000
From: Graham Wood <Graham.letterT.Wood@oracle.com>
Subject: Re: Arrays Of Arrays: Is it an Array or Scalar?
Message-Id: <kguUb.17$af5.22@news.oracle.com>
Hal Vaughan wrote:
> I have a function that I'm using to perform operations on strings in an
> array. There are times where I'd like to have this function work on arrays
> of arrays. Is there a simple way to tell if the value of an element in an
> array is a scalar, or is, instead, a reference to another array?
>
> I know I can use a regex to see if the string matches the pattern for an
> array reference, but is there a more "elegant" and easier way to do it?
>
> (And, while I'm at it, is there a way to check for a hash as well? I'd
> think they'd both be done the same way.)
>
> Thanks!
>
> Hal
You could use the ref function to find out what is in your array
elements. If it isn't a reference to a scalar, an array, a hash, code,
another reference or a glob or lvalue, then you can safely say it's a
scalar. I think. I'm sure someone will correct me if I lie.
perldoc -f ref
ref Returns a true value if EXPR is a reference, false otherwise. If
EXPR is not specified, "$_" will be used. The value returned
depends on the type of thing the reference is a reference to.
Builtin types include:
SCALAR
ARRAY
HASH
CODE
REF
GLOB
LVALUE
Graham
------------------------------
Date: Thu, 05 Feb 2004 08:33:51 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Arrays Of Arrays: Is it an Array or Scalar?
Message-Id: <050220040833519248%jgibson@mail.arc.nasa.gov>
In article <AKtUb.185396$nt4.786330@attbi_s51>, Hal Vaughan
<hal@thresholddigital.com> wrote:
> I have a function that I'm using to perform operations on strings in an
> array. There are times where I'd like to have this function work on arrays
> of arrays. Is there a simple way to tell if the value of an element in an
> array is a scalar, or is, instead, a reference to another array?
>
> I know I can use a regex to see if the string matches the pattern for an
> array reference, but is there a more "elegant" and easier way to do it?
>
> (And, while I'm at it, is there a way to check for a hash as well? I'd
> think they'd both be done the same way.)
>
> Thanks!
>
> Hal
The ref() function returns undef if passed a scalar and a string
describing the type of object pointed to (e.g. ARRAY, HASH) if passed a
reference.
perldoc -f ref
------------------------------
Date: Thu, 05 Feb 2004 16:55:30 GMT
From: Hal Vaughan <hal@thresholddigital.com>
Subject: Re: Arrays Of Arrays: Is it an Array or Scalar?
Message-Id: <5AuUb.224412$I06.2445316@attbi_s01>
Hal Vaughan wrote:
> I have a function that I'm using to perform operations on strings in an
> array. There are times where I'd like to have this function work on
> arrays
> of arrays. Is there a simple way to tell if the value of an element in an
> array is a scalar, or is, instead, a reference to another array?
>
> I know I can use a regex to see if the string matches the pattern for an
> array reference, but is there a more "elegant" and easier way to do it?
>
> (And, while I'm at it, is there a way to check for a hash as well? I'd
> think they'd both be done the same way.)
>
> Thanks!
>
> Hal
Thanks to those who responded and said to use the ref() function. I was
thinking more along the lines of type() or typeof(), and couldn't find
anything like that. Once someone pointed me in the right direction (with
ref() ), it was easy to find more info.
The problem with being self-taught is that there are so many holes like this
where you know there should be something, but you have no idea what it's
called, so it can be hard to find. Once you get a name or term to use,
it's easy.
Thanks.
Hal
------------------------------
Date: 5 Feb 2004 10:34:16 -0800
From: use63net@yahoo.com (Unknown Poster)
Subject: Re: Copy Constructor Craziness
Message-Id: <c62e93ec.0402051034.27e4d2d0@posting.google.com>
Steve May <drumspoorly@reachone.net> wrote in message news:<1023ea5fm0btfc4@corp.supernews.com>...
> Unknown Poster wrote:
> > The behavior I'm seeing in Perl 5.6 contradicts what I understand
> > about copy constructors - specifically, when they are autogenerated.
> >
> > # $f is a reference to an object
> > my $g = $f;
>
> so, assuming that $f is indeed a scalar reference $g now equals
> something like:
>
> SCALAR(0x80545ac)
>
> Is this what you want/expect?
>
> > print "\$g = $g, ";
> > ++$g;
>
> Hmmmm... doesn't look like it, at least it looks like you are
> trying to increment a scalar....
>
> > print "after ++, \$g = $g, \$f = $f\n"; # The value of $g changes,
> > but the
> > # value of $f does not!
> >
>
>
>
> #! /usr/bin/perl -w
> use strict;
>
> my $base = 4;
>
> my $f = \$base;
>
> my $g = $f;
> print "g is $g and f is $f\n";
>
> > g is SCALAR(0x80545ac) and f is SCALAR(0x80545ac)
>
> $$g++;
>
> print "g is $$g, and f is $$f\n";
>
> > g is 5, and f is 5
>
>
> s.
# the code for the Rational class is too long to include in a post
# an object represents a fractional number, so its two data members
# are scalars - the fraction's numerator and denominator
use Rational;
use warnings;
use strict;
my $f = Rational->new(1, 7) ;
my $g = $f;
print "\$g = $g, ";
++$g;
print "after ++, \$g = $g, \$f = $f\n";
------------------------------------------
output is:
$g = 1/7, after ++, $g = 8/7, $f = 1/7
I'm not arguing that this result is "wrong", just that it appears
to be inconsistent with what Programming Perl states about
copy constructors. Again, I do not overload "=" for the
Rational class. Copy constructors are supposedly autogenerated
only when "the object is a plain scalar". I'm not sure what that
means, but don't see how a class with two scalars qualifies for
autogeneration.
------------------------------
Date: Thu, 05 Feb 2004 19:55:27 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Docs comprehensibility
Message-Id: <bvu3gj$100n6u$1@ID-184292.news.uni-berlin.de>
Tassilo v. Parseval wrote:
> Also sprach Gunnar Hjalmarsson:
>> Shouldn't the docs be given high priority? After all, the value
>> of new and/or sophisticated features is limited if they are
>> understood by just a few...
>
> Higher priority than bugfixes and fixing security holes such as the
> hashing exploit that was fixed in 5.8.1? I don't think so.
Neither do I. That was not what I said, was it?
>>> Doc-patches can also be provided by all those people who are
>>> solid Perl programmers but don't understand the perlguts.
>>
>> Would it be that impossible to involve not so solid programmers?
>
> That is already how it is. perlpatch.pod explains in lengthy
> details how to create and submit patches. You don't have to be
> registered or anything to contribute to Perl. Just create a patch
> and send it to perl5-porters@perl.org. The patch will then be
> discussed or, this is my experience, very often just applied
> without further discussion. Let me quote Nicholas Clark, the
> current pumpking for 5.8.2 - 5.8.x:
>
> Calling all happy passive readers of perl5-porters - submit a
> patch, get your name into the AUTHORS file: fame, immortality and
> more spam.
>
> The development of Perl5 happens in a most informal way really and
> is open to anyone. It's not a closed circle.
Thanks for that info, Tassilo. I for one was not aware of that channel
being open to anyone with a (sensible) suggestion.
Maybe I'd pick something, and give it a shot. :)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 05 Feb 2004 19:55:39 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Docs comprehensibility
Message-Id: <bvu3go$100n6u$2@ID-184292.news.uni-berlin.de>
Ben Morrow wrote:
> Gunnar Hjalmarsson wrote:
>> Ben Morrow wrote:
>>> if you know nothing, and in particular with some of the older
>>> docs if you know no C, you have to work quite hard to figure
>>> out what's going on.
>>
>> And what a few of us are trying to say is that that is not very
>> good.
>
> Fine. Fix it, then.
You just asked somebody without any formal programming training, and
who started his programming 'career' a few years ago by modifying Matt
Wright's guestbook script, to fix the Perl documentation. :)
> Personally, I like the docs how they are; if you want them to be
> different, rewrite them.
Maybe you have the presupposed C and *nix background. Even I, without
that background (actually without any background), have begun to get
used to the documentation style, and typically I'm able to figure out
the answer to my questions by help of the docs.
However, I believe that a less 'presupposive' docs would make Perl an
even more attractive programming language, which would be of benefit
to all of us.
>> Standard response, indeed, that did not actually address my
>> point. ;-)
>
> Umm... did it not? I'm not sure whether you class yourself as a
> 'dedicated beginner' or not, but if you do then feel free to put
> forward suggestions for specific changes, ...
Well, I wasn't actually inviting myself to write docs... On the other
hand, my concern may have been based on a misunderstanding with
respect to the way contributors are recruited. Tassilo's post was
clarifying to me.
>> Personally I may try to contribute to the docs some day when I
>> feel confident enough.
>
> If confidence is the only thing stopping you then I would say your
> grasp of both Perl and English is quite sufficient to write a
> decent explanation of sprintf.
I may give it a try. Unless somebody else, who reads this, comes
first, of course. ;-)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 05 Feb 2004 16:49:21 GMT
From: "Monkey Man" <aktanaktas@earthlink.net>
Subject: executing from command line
Message-Id: <luuUb.9762$sQ3.5155@newssvr29.news.prodigy.com>
Hey there,
I have a perl script that i would like to run it on a windows server. Since
there is no command line with windows, i want to execute script from a web
page. Is that possible? Or am i just dreaming?
------------------------------
Date: 5 Feb 2004 16:59:53 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: executing from command line
Message-Id: <Xns94867A0F46737asu1cornelledu@132.236.56.8>
"Monkey Man" <aktanaktas@earthlink.net> wrote in
news:luuUb.9762$sQ3.5155@newssvr29.news.prodigy.com:
>
> Hey there,
> I have a perl script that i would like to run it on a windows server.
> Since there is no command line with windows, i want to execute script
> from a web page. Is that possible? Or am i just dreaming?
You seem to have no idea what you are talking about. Please try to define
the question properly. In doing so, either you will find the answer
yourself, or you'll be helping others help you.
Start -> Run -> command <enter> (Win 9x)
Start -> Run -> cmd <enter> (Win NT,2K,XP)
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: Thu, 05 Feb 2004 17:10:06 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: executing from command line
Message-Id: <Xns94867BC87569Ddkwwashere@216.168.3.30>
Monkey Man <aktanaktas@earthlink.net> wrote:
> I have a perl script that i would like to run it on a windows server.
> Since there is no command line with windows,
Yes there is.
> i want to execute script
> from a web page. Is that possible?
Yes. Sounds like you may want to do CGI. Search the web for CGI FAQ for
more information.
CGI questions should be posted to comp.infosystems.authoring.cgi.
> Or am i just dreaming?
Maybe.
--
David Wall
------------------------------
Date: Thu, 05 Feb 2004 17:24:32 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: executing from command line
Message-Id: <Xns94867E3B3F882dkwwashere@216.168.3.30>
I wrote:
> CGI questions should be posted to comp.infosystems.authoring.cgi.
Oops, make that comp.infosystems.www.authoring.cgi
------------------------------
Date: Thu, 05 Feb 2004 13:00:09 -0500
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: executing from command line
Message-Id: <402284A9.4040102@gwu.edu>
Monkey Man wrote:
> Hey there,
> I have a perl script that i would like to run it on a windows server. Since
> there is no command line with windows,
What the devil ever gave you the impression that there is no command line
with Windows?
Chris Mattern
------------------------------
Date: 05 Feb 2004 18:10:02 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: executing from command line
Message-Id: <u9oesdpfd1.fsf@wcl-l.bham.ac.uk>
Chris Mattern <syscjm@gwu.edu> writes:
> Monkey Man wrote:
> > Hey there,
> > I have a perl script that i would like to run it on a windows server. Since
> > there is no command line with windows,
>
> What the devil ever gave you the impression that there is no command line
> with Windows?
I think he meant no remote access to the command line (like
rlogind/telnetd/sshd as you might find on a real operating system).
These don't come as standard on Windows but you can get them I think.
Anyhow, this has nothing to do with Perl.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 05 Feb 2004 18:36:09 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: executing from command line
Message-Id: <t2wUb.11003$9a7.5572@nwrddc02.gnilink.net>
Monkey Man wrote:
> I have a perl script that i would like to run it on a windows server.
> Since there is no command line with windows,
Really? Since when?
It may not be the most powerful or useful shell, but cmd.exe and command.com
look like command line shells to me.
> i want to execute script
> from a web page. Is that possible?
Well, sure, but why go the difficult route, including all those security
issues.
> Or am i just dreaming?
Well, yes, although on a different topic then you thought.
jue
------------------------------
Date: 05 Feb 2004 18:05:25 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Getting STDERR from forked child processes?
Message-Id: <u9u125pfkq.fsf@wcl-l.bham.ac.uk>
Zbigniew Fiedorowicz <fiedorow@hotmail.com> writes:
> How can I catch error messages from external programs forked
> from a Perl cgi process?
Can you explain how your question differs from the FAQ: "How can I
capture STDERR from an external command?"
Note: the FAQ doesn't mention you can also do fork/reopen STDOUT/exec
as you would in C.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 5 Feb 2004 16:14:45 +0000 (UTC)
From: eric.salgon@mane.com (Eric SALGON)
Subject: How to execute a command line in Perlscript
Message-Id: <bvtq5l$ctl$1@s1.read.news.oleane.net>
Hi,
Is there someone who knows how to execute a command line (such a simple echo
cmd) in PerlScript.
I hve tryed '' or system() but the result is the same: no result but no error
!
This syntax works fine in a perl program but not in PerlScript
An idea ?
Eric
------------------------------
Date: Thu, 05 Feb 2004 17:26:50 GMT
From: Chris <ceo@nospan.on.net>
Subject: Re: How to execute a command line in Perlscript
Message-Id: <u1vUb.19065$po6.10019@newssvr16.news.prodigy.com>
Eric SALGON wrote:
> Hi,
>
> Is there someone who knows how to execute a command line (such a simple echo
> cmd) in PerlScript.
>
> I hve tryed '' or system() but the result is the same: no result but no error
> !
>
> This syntax works fine in a perl program but not in PerlScript
>
> An idea ?
Well, to answer your question successfully, I'll have to make some
assumptions. Some people, when they say "PerlScript," they really mean
"Perl script." But since there IS a product called "PerlScript," I'll
answer in that context. And even within THAT, there are two ways this
could be viewed: PerlScript under ASP and PerlScript under Windows
Scripting Host. I'll assume the later, but answer both.
PerlScript ASP cannot use 'print' or 'echo' to write to the end client
browser. You have to use $Response->Write(). Assuming you know that
already...
...the answer when running PerlScript in a WSH context is:
$WScript->Echo( "This is how to print in PerlScript\n" );
A tip: I personally like Ruby's use of a call named puts() which, named
in C-style convention, out Puts a string. I've adopted THAT as my
standard "outputing call" and I write wrappers in each environment I'm
in to handle it the right way (so I don't have to remember any more how
to write a string; it gets ridiculously out of hand esp. in the Windows
world where Microsoft can't get it together and each side of their house
invents a new standard for something so simple -- in ASP it's
Response.Write in WSH it's WScript.Echo, in Access it's print.debug or
whatever...)
So... I recommend this approach and then you never have to remember any
more:
ASP: sub puts { for (@_) { $Response->Write( "$_\n" ) } }
WSH: sub puts { for (@_) { $WScript->Echo( "$_\n" ) } }
Chris
-----
Chris Olive
chris -at- --spammers-are-vermen-- technologEase -dot- com
http://www.technologEase.com
(pronounced "technologies")
------------------------------
Date: Thu, 05 Feb 2004 17:47:54 GMT
From: Chris <ceo@nospan.on.net>
Subject: Re: How to execute a command line in Perlscript
Message-Id: <elvUb.19067$Fp6.2360@newssvr16.news.prodigy.com>
Eric SALGON wrote:
> Hi,
>
> Is there someone who knows how to execute a command line (such a simple echo
> cmd) in PerlScript.
>
> I hve tryed '' or system() but the result is the same: no result but no error
> !
>
> This syntax works fine in a perl program but not in PerlScript
>
> An idea ?
>
I just realized I didn't answer your question in my last response.
First of all, as a general rule, and one that is outlined in the FAQ
(and asked about a lot here is) system() does NOT provide output. But
most especially in the Windows world where Microsoft writes their own
rules, this is also not the case in either ASP or WSH (still assuming
you are talking about "PerlScript" and not "Perl script.")
Using output wrappers in the ASP and WSH worlds for outputing a string,
the following code will work in both worlds for outputing a "system"
command:
sub shell {
my @output;
for (@_) { push( @output, `$_` ) }
chomp( @output );
return wantarray ? @output : \@output;
}
puts( shell( 'dir /l/on/' ) );
or you can:
puts( shell(
'dir',
'type c:\\autoexec.bat',
'dir c:\\winnt\\system32',
'command4',
'command5',
));
If:
ASP: sub puts { for (@_) { $Response->Write( "$_\n" ) } }
WSH: sub puts { for (@_) { $WScript->Echo( "$_\n" ) } }
Incidentially using PerlScript in Windows allows you this convenience.
The "official" Microsoft "interface" (read "complicated and
convolluted") for executing a command in a scripting environment (both
ASP and WSH) is WshShell.Exec() (which takes two calls to set up.) You
can do this in PerlScript if you want, but the regular Perl way of
executing a system command works much smoother.
HTH,
Chris
-----
Chris Olive
chris -at- --spammers-are-vermen-- technologEase -dot- com
http://www.technologEase.com
(pronounced "technologies")
------------------------------
Date: Thu, 05 Feb 2004 10:27:23 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Perl data types
Message-Id: <etollnha138.fsf@fc.hp.com>
"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> writes:
> Also sprach Eric Schwartz:
>> "David Holmes" <no@spam.uk> writes:
>>> if (instanceOf(superclass1)) { do something }
>>> else if (instanceOf(superclass2)) { do something else }
>>
>> But that's crappy OO programming. You should do
>>
>> object.method()
>>
>> instead, and let inheritance take care of what gets done, no?
>
> No, not in Java. Due to broken-by-design method dispatch, you will
> constantly be checking the type and then do a typecast.
<snip the horror... THE HORROR!>
Well, no wonder I dislike statically-typed OO languages. :P Your
explanation is cogent, sensible, and completely inane. I can't
believe Java programmers stand for that sort of thing.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: 5 Feb 2004 10:13:43 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Perl data types
Message-Id: <402287d7@news.victoria.tc.ca>
Tassilo v. Parseval (tassilo.parseval@rwth-aachen.de) wrote:
: Also sprach Eric Schwartz:
: > "David Holmes" <no@spam.uk> writes:
: >> As for sum types, they are subtly different. Values of a sum type are
: >> tagged. This can take several forms but again in the example of a java.
: >> Incase you cant tell this is the language I use most. If you have a base
: >> class that extends a superclass1 and a superclass2. You can initialise a
: >> variable as the base class, and then say:
: >>
: >> if (instanceOf(superclass1)) { do something }
: >> else if (instanceOf(superclass2)) { do something else }
: >
: > But that's crappy OO programming. You should do
: >
: > object.method()
: >
: > instead, and let inheritance take care of what gets done, no?
: No, not in Java. Due to broken-by-design method dispatch, you will
: constantly be checking the type and then do a typecast. If you have a
: class "Foo" with a method "bar" and you stuff 10 Foo objects into
: Object array[10];
If they are Foo objects, then why pretend they are just generic Objects?
Why not stuff them into
Foo array[10];
Then you can write
array[0].bar();
just like you wish.
: you can't just say 'array[0].bar'. Instead you have to write
: ((Foo)array[0]).bar();
: This gets worse if 'array' contains Foo and Bar objects and both have a
: "bar" method. Then this becomes:
: if (array[0] instanceof Foo) {
: ((Foo)array[0]).bar();
: } else {
: ((Bar)array[0]).bar();
: }
If Foo and Bar are derived from the same class which provides "bar()", or
if they both implement an interface that has bar, then, as above, you can
select a type for the array that is more specific than Object (and more
appropriate), and then the above is not needed.
: Thus, it is often required in Java to do the type checking by hand.
I wonder why UNIVERSAL.pm provides isa() and can()? Perhaps it's because
you have to do these same kind of checks in perl on occasion?
: Therefore I never quite understood how SUN can claim that Java has
: polymorphism at all.
Perhaps because it does?
------------------------------
Date: 5 Feb 2004 08:44:42 -0800
From: g_klinedinst@hotmail.com (G Klinedinst)
Subject: Re: Perl For Amateur Computer Programmers
Message-Id: <168f035a.0402050844.4381d07c@posting.google.com>
Iain Chalmers <bigiain@mightymedia.com.au> wrote in message news:
> Err, let me clarify, I think they have "terrible form" for _some_ of the
> target audience.
Sorry Iain, I wasn't trying to put words in your mouth there. Maybe I
should have qualified that a little more. Let me try again:
I agree with Iain that some of the docs could use a looking over. In
my opinion some of the docs seem to have terrible form which makes
them hard to understand for beginners without previous C or *nix
experience. It also makes them hard to browse through as an
experienced programmer due to the fundemental organization of some of
the documents. It would be worth while to take a look at them and see
which ones could use some improving, keeping users of all levels and
experience in mind.
-Greg
------------------------------
Date: Thu, 05 Feb 2004 17:48:43 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: Perl For Amateur Computer Programmers
Message-Id: <%lvUb.21747$sg5.13065@newssvr25.news.prodigy.com>
Michele Dondi <bik.mido@tiscalinet.it> wrote:
>>And, just to be pedantic, ISO call a million bytes a megabyte (MB),
>>and 1024^2 bytes a megibyte (MiB), for the sake of consistency with
>>the rest of the ISO system.
> I had heard that, probably in a post similar to this one. And I must
> say it does make sense, but it is a matter of a fact that most people
> *and programs* think that e.g. a megabyte is 1024^2.
Hmm. I used to think that. I really think it depends on context
though.
I think that if I ask people how big is this file...
-rw-r--r-- 1 root other 20189240 Feb 3 12:04 nw_sol.tar.gz
most of them will say "20 megabytes" because they do the "yank 6 digits"
operation that is equivalent to dividing by 10^6.
I think this is even more true with GB range files...
-rw-r--r-- 1 root other 1030189240 Feb 3 12:04 nw_sol.tar.gz
Quick. How big? That's a Gigabyte, right?
1030189240 / 10^9 => 1.03
1030189240 / 2^30 => 0.95
--
Darren Dunham ddunham@taos.com
Senior Technical Consultant TAOS http://www.taos.com/
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
------------------------------
Date: Thu, 05 Feb 2004 12:23:03 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: problem with "our"
Message-Id: <qZadnWnuBMlq5r_dRVn-jg@adelphia.com>
JaSeong Ju wrote:
> our $choice = 67.90;
> Is perl version 5.005_03 too old?
Yes. "our" was introduced in 5.6.
sherm--
------------------------------
Date: 05 Feb 2004 09:21:51 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: J Krugman <jill_krugman@yahoo.com>
Subject: Re: RDBMS to hold Perl objects?
Message-Id: <861xp9saq8.fsf@blue.stonehenge.com>
*** post for FREE via your newsreader at post.newsfeed.com ***
>>>>> "J" == J Krugman <jill_krugman@yahoo.com> writes:
J> Is there a free RDBMS that can handle Perl objects?
Well, "R" != "O", so you'll have to go through some impedence mismatch
translation at some level.
If you want a free RDBMS, there's plenty. I recommend DBD::SQLite as
a serverless solution, or DBD::Pg and PostgreSQL as a proper database.
Stay away from MySQL for new installations, no point in it anymore.
If you want to map Perl objects to a RDBMS, look at Tangram, Alzabo,
or Class::DBI, depending on how much you want to let Perl drive or you
drive. If you want to swizzle arbitrary objects, you'll probably have
to roll your own Storable filter as blobs, but then you get no support
on the DB side to peer into the opaque box.
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <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!
-----= Posted via Newsfeed.Com, Uncensored Usenet News =-----
http://www.newsfeed.com - The #1 Newsgroup Service in the World!
-----== 100,000 Groups! - 19 Servers! - Unlimited Download! =-----
------------------------------
Date: Thu, 5 Feb 2004 18:19:27 +0000 (UTC)
From: J Krugman <jill_krugman@yahoo.com>
Subject: Re: RDBMS to hold Perl objects?
Message-Id: <bvu1ff$h8f$1@reader2.panix.com>
Many thanks!
jill
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 6084
***************************************