[8719] in Perl-Users-Digest
Perl-Users Digest, Issue: 2336 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 16 10:07:18 1998
Date: Thu, 16 Apr 98 07:00:33 -0700
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, 16 Apr 1998 Volume: 8 Number: 2336
Today's topics:
?? Perform a remote query and reformat results j5rson@iversonsoftware.com
Array / List question <road@apdo.com>
Re: Array / List question <qdtcall@esb.ericsson.se>
Re: Array / List question <jdporter@min.net>
Re: Array / List question <grinch@whoville.com>
Re: Bill Gates should be invited to O'Reilly's "Free So <sutok@gmx.de>
cgi comes up e icon in windows 95 tiles@pyramidtile.com
Re: contexts: is there such a thing as array? (M.J.T. Guy)
Re: hash/complex data structure problem <jdf@pobox.com>
Re: Info Regarding Perl 5.005 <pdcawley@bofh.org.uk>
Re: looking for a good win32 perl editor. <nospam-R.J.Rainthorpe@gre.ac.uk>
minneapolis perl mongers <spimac@inetsource.com>
Re: My macperl scripts don't shut down after 5 minutes (Chris Nandor)
Re: OOPS and several parents <tchrist@mox.perl.com>
Re: OOPS and several parents (Andy Wardley)
Re: Perl 5.004_64 Slower??? (Stuart McDow)
Re: Perl Module or Script for difference of two files <jdf@pobox.com>
Re: Problem building perl on HPUX 10.20 <sdh1@anchor.hotmail.com>
push a non HTML document to a web browser? <fgculp@YOUKNOWWHATTODO.vianet.net.au>
Re: question of interest: How does perl compile? <jdf@pobox.com>
Re: sleep & print in cycles <jdf@pobox.com>
unix commands in a perl <soetensi@se.bel.alcatel.be>
Re: Viewing perl abstract data structures <jefpin@bergen.org>
Re: Which Win32 Perl <jefpin@bergen.org>
Re: Which Win32 Perl <msergeant@ndirect.co.uk>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 16 Apr 1998 08:48:57 -0600
From: j5rson@iversonsoftware.com
Subject: ?? Perform a remote query and reformat results
Message-Id: <6h5289$3aq$1@nnrp1.dejanews.com>
I want to perform a POST query on another server, capture the results and
reformat them for display.
How can I simulate a POST from Perl, capture the results in the script,
reformat and display for my user?
I don't really have a problem with the reformat or the display issues, just
the POST and capture within my script.
Please email any ideas.
Jeff Iverson
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Thu, 16 Apr 1998 14:13:37 +0200
From: "A.P." <road@apdo.com>
To: road@apdo.com
Subject: Array / List question
Message-Id: <3535F5F1.FAD8C08E@apdo.com>
Hi!
I don't understand the behaviour of the following code:
print ((0,4)**2);
It prints 16, why doesn't it print 0? I discovered this trying to do it
with an array. I'm a Perl beginner and I wondered if there was a way of
doing some operation (like squaring) all the elements of an array/list
without using a loop block. What I tried was:
@i=(0..4);
@j=@i[@i]**2;
print @j;
I thought that it should print 25, but it prints 16!!! I say this
because an array in an scalar context I think it should return the
number of elements, not the value of the last one. Please help! I can't
stand not knowing the solution! Thanks a lot!
------------------------------
Date: 16 Apr 1998 15:07:15 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Array / List question
Message-Id: <is3efdewzg.fsf@godzilla.kiere.ericsson.se>
"A.P." <road@apdo.com> writes:
> I say this because an array in an scalar context I think it should
> return the number of elements, not the value of the last one.
It does. You don't have a scalar context.
--
Calle Dybedahl, UNIX Sysadmin
qdtcall@esavionics.se http://www.lysator.liu.se/~calle/
------------------------------
Date: Thu, 16 Apr 1998 13:28:08 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Array / List question
Message-Id: <353608D3.3931@min.net>
A.P. wrote:
>
> I don't understand the behaviour of the following code:
>
> print ((0,4)**2);
>
> It prints 16, why doesn't it print 0?
> I discovered this trying to do it with an array.
It does not work on an array. The docs clearly state that
math ops like this work on scalars.
Since (0,4) is being interpreted as a scalar, it's taking
the last element, namely 4.
> I'm a Perl beginner and I wondered if there was a way of
> doing some operation (like squaring) all the elements of an array/list
> without using a loop block.
If by loop you mean a for loop, then sure: use map. Like this:
@x_squared = map { $_ ** 2 } @x;
> What I tried was:
>
> @i=(0..4);
> @j=@i[@i]**2;
> print @j;
>
> I thought that it should print 25, but it prints 16!!! I say this
> because an array in a scalar context -- I think it should return the
> number of elements, not the value of the last one.
It only returns the number of elements when the expression consists
of a plain array variable. Array slices, such as you have here,
return the last element.
By the way, an expression such as @x[@x] is risky; it only happens
to be meaningful if all the values in the array are in the range
of indices of the array (i.e. in (0..$#x)), such as in the example
above. Otherwise, some values in the result will be undef.
hth,
John Porter
------------------------------
Date: Thu, 16 Apr 1998 09:38:49 -0400
From: "Grinch" <grinch@whoville.com>
Subject: Re: Array / List question
Message-Id: <6h50rt$27e@fridge.shore.net>
A.P. wrote in message <3535F5F1.FAD8C08E@apdo.com>...
>Hi!
>I don't understand the behaviour of the following code:
>
>print ((0,4)**2);
>
>It prints 16, why doesn't it print 0?
When used in a scalar context, as it is above, a list's value is the value
of the last element. The exponent operator expects a scalar on the left, so
the above list (0,4) is evaluated in scalar context, resulting in the value
4.
>doing some operation (like squaring) all the elements of an array/list
>without using a loop block.
You can use foreach. It is a loop construct, but the loop index is handled
for you automatically. Here's an example, lifted nearly verbatim from the
Camel Book, pp. 100:
foreach $elem (@elements) {
$elem **= 2;
}
HTH!
-grinch
--
-----
"Yes, I'm paranoid, but that doesn't mean
no one's out to get me." - me
Sherm Pendley
grinch@whoville.com
http://www.whoville.com
------------------------------
Date: 16 Apr 1998 13:47:20 GMT
From: Florian Kuehnert <sutok@gmx.de>
Subject: Re: Bill Gates should be invited to O'Reilly's "Free Software Summit" (was Re: RMS should be invited to O'Reilly's "Free Software Summit")
Message-Id: <6h5258$ifs$4@babelon.in-brb.de>
In gnu.misc.discuss Andreas Borchert <borchert@turing.mathematik.uni-ulm.de> wrote:
>Sure. And do not have problems with that. Later up in the thread it
>was stated (without examples) that there are cases where the only
>available documentation was non-free.
Well, imagine I would write a free, but very complex program but the
only documentation I'd write was a O'Reilly book. Wouldn't it be "free
software" then (the program, not the book)?
Would it be "free software" if I'd write no documentation at all?
What defines "software" in the GPL?
Florian
------------------------------
Date: Thu, 16 Apr 1998 08:23:25 -0600
From: tiles@pyramidtile.com
Subject: cgi comes up e icon in windows 95
Message-Id: <6h50od$1a9$1@nnrp1.dejanews.com>
I am operating a Windows 95 computer. I just downloaded Solena Sol's
Web_store.
In order for this program to run right, I need to get each file in their
proper directory, folder and subfolder correctly before I upload. It is a Tar
file as well.
I proceeded to open up WinZip to open up web_store and found the
web_store.cgi file along with 71 others. The best I can do, in order to
actually read it is to open it up in Wordpad. When I do this, it opens up and
I can read it. Now here is the problem:(,! When ever I save it to the
web_store folder on my desktop, I consistantly recieve a dreaded small icon:(
When I can save it to the web_store folder I created, it can saves it as a
Word file and its icon will mention Word.
But the second you click on it, it comes up a little tiny icon
in the left hand corner of a window, with white backround. When I go back to
check the web_store folder it takes the form of "e" icon:(:(:(. This happens
over and over and over again.
Can some kind soul come to the rescue, I have been working on this much too
long........
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 16 Apr 1998 12:36:47 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: contexts: is there such a thing as array?
Message-Id: <6h4u0v$d7h$1@lyra.csx.cam.ac.uk>
Tye McQueen <tye@fohnix.metronet.com> wrote:
>John Porter <jdporter@min.net> writes:
>)
>) The bizarre thing (to me) is that in
>)
>) scalar @foo{ EXPR1, EXPR2 }
>)
>) the comma is behaving in a scalar context, yet EXPR1 and EXPR2 are
>) being evaluated in a list context. Not that that's bad, just
>) perhaps somewhat counterintuitive?
>
>Sounds like a bug to me. A subtle bug, sure. I suspect that
>perl's hash slice code is not passing the scalar context to the
>inner list but instead special-cases scalar context to return the
>last item of the slice.
Not really a bug; just a case of being careful about how you describe the
behaviour. The comma isn't really behaving in any sort of context,
since this is syntax which is parsed specially, so the comma isn't an
operator at all, just another piece of line noise.
The fact that the semantics (and the syntax) is the same as if the comma
_were_ a scalar-context comma operator, but with its operands evaluated in
list context, just serves to keep you on your toes.
Mike Guy
------------------------------
Date: 16 Apr 1998 09:24:06 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: hash/complex data structure problem
Message-Id: <btu1kfp5.fsf@mailhost.panix.com>
Mika Koivisto <mika@wcug.wwu.edu> writes:
> '3' => {
> 'price' = '22',
> 'setup' = '0',
> 'other'
> },
This code shouldn't even compile. That's not a valid hash
constructor. I think you mean the comma-synonym "=>" instead of the
assignment operator. Also, you're not specifying a value for what I
assume you intended to be the 'other' key.
> Now the problem is that I need to walk trough each item on that structure
> and crap the price, setup and other and then do something with them.
^^^^
autoflush, maybe?
> Could someone help me out with the traverse code.
You'll want to read perlref, perldsc, and perllol. Once you've read
and understood those manpages, you'll know that to traverse the keys
of a hash referenced by $hashref, you refer to
keys %$hashref
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: 16 Apr 1998 15:24:28 +0200
From: Piers Cawley <pdcawley@bofh.org.uk>
Subject: Re: Info Regarding Perl 5.005
Message-Id: <s7phg3tdhmb.fsf@olorin.elsevier.nl>
ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
> [A complimentary Cc of this posting was sent to Malcolm Beattie
> <mbeattie@sable.ox.ac.uk>],
> > Since the original requestor wanted to know about the new features
> > in 5.005, not just the multithreading, I probably ought to mention
> > the bundled compiler (which has a Lint module and a (naive)
> > cross-reference module along with its "real" compiler parts) and
> > some support for strong typing and parse-time optimised access to
> > array refs via hash key syntax. Ilya's added some new regexp features.
>
> *And* major optimizations.
Okay, so how much of Friedl's book is going to be irrelevant once
5.005 hits the streets?
--
Piers Cawley
Where is the life we have lost in living?
Where is the wisdom we have lost in knowledge?
Where is the knowledge we have lost in information? -- T. S. Eliot.
------------------------------
Date: 16 Apr 1998 13:11:55 +0100
From: Rob Rainthorpe <nospam-R.J.Rainthorpe@gre.ac.uk>
Subject: Re: looking for a good win32 perl editor.
Message-Id: <ulnt6m0dw.fsf@gre.ac.uk>
My mileage appears to vary (MMATV), since I haven't any problems with
20.2, except that menus can be corrupted on first opening a frame. As
soon as you click on any menu, the real menu text appears.
Earlier versions of cperl-mode had problems with constructs such as:
while (<>) {
}
whereby you couldn't type the "<". This was a fairly critical
problem. The last five or six point increments have been fine,
though. I finally deleted 19.34.6 about three weeks ago, since I could
successfully work with cperl and the JDE java mode. So far, I haven't
regretted moving wholesale to the new version.
But I'd echo your comments all the same! Stick with 19.34 if it works
for you - try 20.2 if you like a little risk. After all, the scroll
bar looks a lot nicer on the left of the screen.
Rob.
drummj@mail.mmc.org (Jeffrey R. Drumm) wrote: >
> The standard GNU source distribution of 20.2 needs a couple of
patches to work > properly with Ilya's CPerl-mode . . . I don't think
those patches are rolled > into the NT binary distribution (I switched
back to 19.34 because of some > wierdness I experienced). YMMV. I'd
recommend sticking with 19.34 for now; > 20.2 does add MULE and
Custom, but we've lived without those for a long, long > time
. . . :-) >
--
Robert Rainthorpe - Central Systems Group, Computing Services
the University of Greenwich
16 - 32 Wellington Street, Tel. (+44) (0)181 331 8738
Woolwich, Fax. (+44) (0)181 331 8385
London SE18 6PF Email. (remove nospam- from above)
------------------------------
Date: Thu, 16 Apr 1998 08:26:29 -0500
From: Patrick McNamee <spimac@inetsource.com>
Subject: minneapolis perl mongers
Message-Id: <35360705.3F4A@inetsource.com>
announcing the formation of minneapolis perl mongers
plans for first meeting are in process
contact:
Patrick McNamee
spimac@inetsource.com
------------------------------
Date: Thu, 16 Apr 1998 08:38:37 -0400
From: pudge@pobox.com (Chris Nandor)
Subject: Re: My macperl scripts don't shut down after 5 minutes as they are supposed to!
Message-Id: <pudge-1604980838380001@ppp-24.ts-1.kin.idt.net>
In article <3301166F.6847@callisto.si.usherb.ca>,
eslcafe@callisto.si.usherb.ca wrote:
# OK - we know we are doing something wrong! My macperl apps don't shut
# down automatically after 5 minutes! And my server admin is in a tizzy.
This seems to be a problem when one .acgi tries to exectute when MacPerl
is busy with another one. Some web servers treat all CGIs as .acgi, and
some will only do that if you name them .acgi instead of .cgi.
Regardless, if you have this problem, you should try to get them to NOT
execute asynchronously until the problem is fixed.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
#== New Book: MacPerl: Power and Ease ==#
#== Publishing Date: Early 1998. http://www.ptf.com/macperl/ ==#
------------------------------
Date: 16 Apr 1998 12:31:06 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: OOPS and several parents
Message-Id: <6h4tma$4rr$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
:John, thanks for the help. Your code works
:well but I'm still looking for more automation.
:What if I didn't know the number of parents?
:
:$#something::ISA gives me the number of items
:in ISA but how can I convert something::new
:so that it reblesses the hash references
:from all it (unknown number of) parents?
Don't rebless. Only the class without SUPER parents should allocate.
Everyone else has to call an _init style method. This fails if you
inherit from classes with a common parent, of course, as I point
out in perltoot. Here's one approach
sub spawn {
my $this = shift;
my $class = ref $this || $this;
my $parent = ref $this && $this;
my $self = @ISA ? $this->SUPER::spawn(@_)
: bless({}, $class);
$self->_init($parent, @_);
return $self;
}
Admittedly there are plenty of nits to pick here regarding the @ISA
check and the assumption that a hash rep is used to build the object.
It would be nice to use the UNIVERSAL can() method, but that doesn't help.
Perhaps the lesson is that multiple inheritance is heretical devilwork.
Following is a first-draft (not even proofed) of a bit from the Perl
Cookbook, due out this summer, that talks about this. Constructive
feedback welcome.
--tom
Creating an Object Constructor
Problem
You need to create a constructor for your class so users can generate
new objects.
Solution
Unlike a constructor method in C++, in Perl, the constructor must
not only initialize its object, but also first allocate memory for
it, typically using an anonymous hash. Rather than call it `new',
we'll call this constructor `spawn'. [FOOTNOTE: If you just can't
stop yourself, you may call it new instead, but realize you're just
giving the C++ programmers a false sense of security. Plus they'll
try to call it using indirect object style and risk getting themselves
really messed up.]
# in Frobniz.pm, do this:
package Frobniz;
sub spawn {
my $classname = shift; # What class are we constructing?
my $obref = {}; # Allocate new memory
bless($obref, $classname); # Mark it of the right type
$obref->_init(@_); # Call _init with remaining args
return $obref;
}
# "private" method to initialize fields
sub _init {
my $ob = shift;
$ob->{START} = time();
$ob->{COUNT} = 0;
if (@_) {
my %extra = @_;
@$ob{keys %extra} = values %extra;
}
}
# back in main program, do this:
use Frobniz;
$ob = Frobniz->spawn();
Discussion
Any method that allocates and initializes a new object acts as a
constructor. The most important thing to remember is that a reference
isn't an object until `bless' has been called on it. The simplest
possible constructor, although admittedly not particularly useful,
is the following:
sub spawn { return bless({}) }
That's a bit too simple, so let's add some initialization.
sub spawn {
my $self = { }; # empty anon hash
bless($self);
# init two sample attributes/data members/fields
$self->{START} = time();
$self->{COUNT} = 0;
return $self;
}
The reason this isn't very useful is that it can't be usefully
inherited from, nor can it usefully override an inherited
constructor. It will always be marked as being of the current class,
never the derived one. To solve this, pay attention to the first
argument, which in the case of a class method, is just the name of
the class. Make sure to call `bless' with that class as the second
argument.
sub spawn {
my $classname = shift; # What class are we constructing?
my $obref = {}; # Allocate new memory
bless($obref, $classname); # Mark it of the right type
$self->{START} = time(); # init data fields
$self->{COUNT} = 0;
return $obref; # And give it back
}
Now the constructor can can be correctly inherited by a derived class.
Accessing Overridden Methods
Problem
You need to write a constructor that has overriden in its base class.
Solution
Learn about the special virtual base class, SUPER.
sub meth {
my $this = shift;
$this->SUPER::meth();
}
Discussion
What happens if this class is itself a derived class, that has
its own constructor? Will the constructor given in the previous
recipe work out? Possibly, but possibly not. In languages like C++
where constructors don't actually allocate memory, but instead just
initialize the object, all base class destructors are automatically
called for you. In other languages, including Java and Perl, this
is not the case: you have to call them yourself.
While regular method calls look like this To call a method in a
particular class, the notation `$ob->SUPER::meth()' is used. This
is just an extension of the regular notation to start looking in a
particular base class, but is only valid from within an overridden
method. Here's a comparison of styles:
$ob->meth(); # Call wherever first meth is found
$ob->Where::meth(); # Start looking in package "Where"
$ob->SUPER::meth(); # Call overridden version
Simple users of the class should probably limit themselves to the
first one. The second is possible, but not suggested. And the last
can only be called from within the overridden method.
An overridden constructor should call its SUPER's constructor to have
it allocate and bless the object, and limit itself to instantiating
any data fields needed. It makes sense at this point to separate the
object allocation code from the object initialization code. We'll
name it with a leading underscore, which is a convention indicating
a nominally private method; think of it as a "Do Not Disturb" sign.
sub spawn {
my $classname = shift; # What class are we constructing?
my $obref = $classname->SUPER::spawn(@_);
$obref->_init(@_);
return $obref; # And give it back
}
sub _init {
my $self = shift;
$self->{START} = time(); # init data fields
$self->{COUNT} = 0;
$self->{EXTRA} = { @_ }; # anything extra
}
Both `SUPER::spawn' and `_init' have been called with any remaining
arguments. That way the user might pass other field initializers in,
as in:
$ob = Frobniz->spawn( haircolor => red, freckles => 121 );
Whether you store these user parameters in their own extra hash or
not is up to you.
Sometimes you find yourself needing another object of the same type
as the current one. You could do this:
$ob1 = SomeClass->spawn();
# later on
$ob2 = (ref $ob1)->spawn();
But that's not very clear, and it doesn't solve another interesting
issue: what if you'd like a constructor called on a class to have
some default initialization, but when called on object to initialize
it from the current object? Imagine you've built a linked list
or a binary tree class, and and then decided to create a derived
class where new nodes contained links that point back to their
parents. That would be most easily coded up where your treated the
constructor sometimes as a class method, and sometimes as an instance
method. [FOOTNOTE: Some purists may tell you this is abhorrent, but
they're just trying impose their pet non-Perl language's emotional
baggage on Perl. Ignore them.]
$ob1 = Frobniz->spawn();
$ob2 = $ob1->spawn();
Here's a version of `spawn' that takes this into consideration:
sub spawn {
my $proto = shift;
my $class = ref($proto) || $proto;
my $parent = ref($proto) && $proto;
### if we're shadowing a spawn from @ISA
# my $self = $proto->SUPER::spawn(@_);
### otherwise :
my $self = {}; # assume we have no @ISA
bless($self, $class);
$self->{PARENT} = $parent;
$self->{START} = time(); # init data fields
$self->{COUNT} = 0;
return $self;
}
--
Tom Christiansen tchrist@jhereg.perl.com
I think I'm likely to be certified before Perl is... :-)
--Larry Wall in <1995Feb12.061604.6008@netlabs.com>
------------------------------
Date: Thu, 16 Apr 1998 13:37:18 GMT
From: abw@cre.canon.co.uk (Andy Wardley)
Subject: Re: OOPS and several parents
Message-Id: <ErIDu6.FBM@cre.canon.co.uk>
Daniel <daniel.mendyke@digital.com> wrote:
>I understand that my example will not work
>because 'SUPER' only calls the first method
>it finds. So my question is 'How do I call
>all four constructors?'
The way multiple base class constructors get called in C++ is somewhat
foreign to Perl. In C++, the constructor gets implicitly passed a pointer
(*this) to the created object. In Perl, it is the responsibility of the
constructor to actually create the object and bless it into a specific
class.
e.g.
sub new { # doesn't have to be called new()
my $class = shift; # class of object we're expected to create
bless { }, $class; # create an anon hash and bless into $class
}
If you call multiple base class constructors then you run the risk of
creating multiple objects.
There are two ways round this. First, have your constructor call an
initialization routine which actually sets the internal values.
package Mother;
sub new {
my $class = shift;
my $self = { };
bless $self, $class;
$self->_mother_init();
$self;
}
sub _mother_init {
my $self = shift;
$self->{ 'mom' } = 'You never call me anymore.';
}
That way it is possible to call the base class initialiser and set the
variables without calling the constructor and creating a new object.
package Child;
@ISA = qw( Mother Father );
sub new {
my $class = shift;
my $self = { };
bless $self, $class;
$self->_mother_init();
$self->_father_init();
$self;
}
You still have the problem that multiple initializer functions with the
same name will be masked. You can work around this, as above, by specifically
naming each initializer to avoid name clashes. It works, but it leaves
a funny taste in the mouth.
In the case where the multiple inheritance is linear (i.e. D isa C, C isa B,
B isa A) you can simply have each constructor call the SUPER constructor,
which in turn calls its SUPER constructor, etc. This works equally well
for separate initializer methods.
package Grandpa;
sub new {
my $class = shift;
my $self = { };
bless $self, $class;
$self->_init();
$self;
}
sub _init {
my $self = shift;
$self->{'gramps'} = 'This is the grand-father';
}
package Father;
use vars qw( @ISA );
@ISA = qw( Grandpa );
sub _init {
my $self = shift;
$self->SUPER::_init();
$self->{'pa'} = 'This is the father';
}
package Child;
use vars qw( @ISA );
@ISA = qw( Father );
sub _init {
my $self = shift;
$self->SUPER::_init();
$self->{'kid'} = 'I am only a child';
}
package main;
my $foo = Child->new();
In this case, the Grandpa constructor is called (via inheritance) to
create the Child and then calls the Child _init() which in turn calls
the Father _init() which in turn calls the Grandpa _init(). The Child
object correctly has the 'kid', 'pa' and 'gramps' data members set.
The final (and most flexible) approach would be to create a constructor
for your derived class which instantiates each of the parent classes
and then combines the relevant member data into a new super-set which
is blessed into the derived class. This tends to break the encapsulation
of the parent classes (because the child must know about the contents
of the parent), but I tend to think it's more in keeping with Perl's
philosophy of "Get the job done" at the risk of offending the object
purists.
package Combo;
use vars qw( @ISA );
@ISA = qw( Foo Bar );
sub new {
my $class = shift;
bless { %{ Foo->new() }, %{ Bar->new() } }, $class;
}
Perhaps it's a limitation of Perl's object model that you have to jump
through a few hoops to do this kind of thing, but it's a testament to
its power and flexibility that you can do it at all when you need to.
A
--
Andy Wardley <abw@kfs.org> http://www.kfs.org/~abw
Signature lost in transit. We apologise for any inconvenience caused.
------------------------------
Date: 16 Apr 1998 13:41:23 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: Perl 5.004_64 Slower???
Message-Id: <6h51q3$qh7$1@ns1.arlut.utexas.edu>
Bill 'Sneex' Jones <sneaker@earthling.net> writes:
>
> I think I will keep the 'without thread support' for now...
If your system supports fork(), there is no need for threads
whatsoever.
--
Stuart McDow Applied Research Laboratories
smcdow@arlut.utexas.edu The University of Texas at Austin
"It is obvious that about 750,000 people ago, Austin was a wonderful City."
------------------------------
Date: 16 Apr 1998 09:28:50 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: "Burkhard Kiesel" <burkhard.kiesel@med.siemens.de>
Subject: Re: Perl Module or Script for difference of two files
Message-Id: <af9lkfh9.fsf@mailhost.panix.com>
[posted and mailed to cited author]
"Burkhard Kiesel" <burkhard.kiesel@med.siemens.de> writes:
> Unfortunatly I was forced to move from SUN's to Windows-NT 4.0, and there is
> really no adequate system command like the "unix - diff".
The "Unix diff" itself is available as part of the Cygwin32 user tools
distribution, along with many other of your favorite command-line
tools.
http://www.cygnus.com/misc/gnu-win32/
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Thu, 16 Apr 1998 09:06:25 -0400
From: "Scott" <sdh1@anchor.hotmail.com>
Subject: Re: Problem building perl on HPUX 10.20
Message-Id: <6h4vu8$a49$1@camel19.mindspring.com>
Mark Frost wrote in message <3535170A.2DEB14F4@horizsys.com>...
>I'm trying to build perl 5.004-04 using gcc 2.8.1 under HPUX 10.20.
>Most of the compilation goes fine, but it ends up showing me:
>
>./miniperl configpm tmp
>sh mv-if-diff tmp lib/Config.pm
>File lib/Config.pm not changed
>./miniperl -Ilib pod/pod2html.PL
>Extracting pod2html (with variable substitutions)
>./miniperl -Ilib pod/pod2latex.PL
>Extracting pod2latex (with variable substitutions)
>./miniperl -Ilib pod/pod2man.PL
>Extracting pod2man (with variable substitutions)
>./miniperl -Ilib pd/pod2text.PL
>Extracting pod2text (with variable substitutions)
> AutoSplitting perl library
>AutoSplitting Text::ParseWords (lib/auto/Text/Parsewords)
>/bin/sh: 7072 Memory fault(coredump)
>make: *** [preplibrary] Error 139
>
>
>It would appear that this is miniperl core dumping when trying to
>autosplit lib/Text/ParseWords.pm.
>
>I was unable to find anything in the FAQ about this. Has someone else
>perhaps come across this problem?
>
>Thanks
>
Well, I just installed it 2 days ago on HP/UX 10.2 but with regular cc, and
it compiled ok. You might try switching compilers.
-Scott
------------------------------
Date: Thu, 16 Apr 1998 20:34:49 +0800
From: "Paul" <fgculp@YOUKNOWWHATTODO.vianet.net.au>
Subject: push a non HTML document to a web browser?
Message-Id: <6h4tmh$a03$1@yeppa.connect.com.au>
We are implementing a document management system that effectively hides the
true path to any file that is stored in the document management system. When
you save a file you are allocated a number and the DMS saves the file
somewhere unknown to you. A SQL server database holds the table that maps a
file number to a specific path.
I want to be able to link to these documents in HTML but all I have about
the document is the document number..
I have gotten a perl script to run an SQL statement against the DMS tables
that will extract the document path given the document number. What I then
want to do is run this script as a CGI and once the path to the document is
obtained, 'push' the document to the browser. ie
http://server/doc.cgi?12323
So to reiterate, the cgi would run an ODBC query to determine the path for
document 12323 and then redirect the browser or send the file to the
browser. If I redirect, I don't want the URL to change (can that be done?).
I don't want users to see the full path to the file via URL.
Is is possible to open a binary file like MSWord and send it to STDOUT?
(assuming you send the right MIME type first?)
any answers or suggestions appreciated..
Paul Culmsee
------------------------------
Date: 16 Apr 1998 09:43:45 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: question of interest: How does perl compile?
Message-Id: <4sztkese.fsf@mailhost.panix.com>
"Frank L. Quednau" <quednauf@nortel.co.uk> writes:
> &format_hd if $action=1;
> &write_randomly_to_memory if $action=2;
It looks to me like you're going to format your drive *and* write
randomly to memory.
> if $action comes from a form and is set to 1, how is the script
> compiled? The whole thing or just the code on top and the
> &format_hd subroutine? Can I influence that? Is there any FAQ?
You're asking about some advanced ideas in Perl, and haven't yet
mastered some of the basics. But, if you'd like some rope, then
please read the documentation for AutoSplit, and perlmod, and probably
a few other things. But you really ought to read the book _Learning
Perl_, before you jump into that stuff.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: 16 Apr 1998 09:38:26 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: sleep & print in cycles
Message-Id: <67k9kf19.fsf@mailhost.panix.com>
uph@is.pdas.cz (Petr Hrbek) writes:
> How can I force the script output to be written during cycle?
You need to set the $| variable. In other words,
$|++; #or $| = 1, whichever you prefer.
Please see the dicussion of $| in perlvar.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Thu, 16 Apr 1998 15:33:11 +0200
From: Inge Soetens <soetensi@se.bel.alcatel.be>
Subject: unix commands in a perl
Message-Id: <35360897.506F@se.bel.alcatel.be>
Hi,
how can I execute some normal UNIX-commands from a perl script ?
I tried to use "system" and "exec",
but something seems to go wrong.
Can anyone help ?
Here I include a simple script, just to change the read/write
permissions of a list of files.
Just to try it.
$file = " find . -name '*.pr' |" ;
open (FIND, $file );
while ($line = <FIND>) # while notEOF
{
print $line;
exec "/usr/bin/chmod -f 0755 $line" ;
}
close FIND ;
The code is executed until it arrives the "exec" statement.
There it stops.
------------------------------
Date: Thu, 16 Apr 1998 08:07:22 -0400
From: Jeff Pinyan <jefpin@bergen.org>
To: no_spam@winzig.com
Subject: Re: Viewing perl abstract data structures
Message-Id: <Pine.SGI.3.95.980416080620.6631B-100000@vangogh.bergen.org>
># %h1 = {
># this => that
># %h2 = {
># 1 => 2
># 2 => 4
># 3 => 6
># 4 => 8
># };
># @a2 = [
># aa
># bb
># cc
># dd
># ee
># ff
># ];
># };
># @a1 = [
># jane
># harriet
># ozzy
># ];
># };
I really hope this gave you errors... it should have!
%hash = ( ... ); #NOT %hash = { ... }
@array = ( ... }; #NOT @array = [ ... ]
--
Four fingers cramped up writing you this email.
- Jeff Pinyan
Jeff Pinyan | users.bergen.org/%7Ejefpin | techmaster@bergen.org
ICQ# 10222129 | 10222129@pager.mirabilis.com | qw[jeff] on EFnet
&jp('"($``','','$)EDF8```','$*52J4```','$+E1G4```','#J``@','#2__`');sub
jp{for$w(@_){$_=unpack('B48',unpack('u',$w));$c=~tr/10/# /;print;}}
------------------------------
Date: Thu, 16 Apr 1998 08:04:22 -0400
From: Jeff Pinyan <jefpin@bergen.org>
To: Rob Greenbank <rob@frii.com>
Subject: Re: Which Win32 Perl
Message-Id: <Pine.SGI.3.95.980416080350.6631A-100000@vangogh.bergen.org>
>I've read the description of the differences between "Active State"
>and "Gurusamy Sarathy's" versions. I like the sounds of GS's, but
>before I blow away my "Active State" version I'd like to know if
>anyones had any problems with GS's. Also, anyone had problems
>switching between the versions?
Far and away, Gurusamy's is the best. I had no problems/qualms about
switching... do yourself and favor and change as soon as you can.
--
On ne voit bien qu'avec le coeur. L'essentiel est invisible pour
les yeux.
- Antoine St-Ex
Jeff Pinyan | users.bergen.org/%7Ejefpin | techmaster@bergen.org
ICQ# 10222129 | 10222129@pager.mirabilis.com | qw[jeff] on EFnet
&jp('"($``','','$)EDF8```','$*52J4```','$+E1G4```','#J``@','#2__`');sub
jp{for$w(@_){$_=unpack('B48',unpack('u',$w));$c=~tr/10/# /;print;}}
------------------------------
Date: Thu, 16 Apr 1998 14:05:45 +0100
From: Matt Sergeant <msergeant@ndirect.co.uk>
Subject: Re: Which Win32 Perl
Message-Id: <35360229.4500@ndirect.co.uk>
Jeff Pinyan wrote:
>
> >I've read the description of the differences between "Active State"
> >and "Gurusamy Sarathy's" versions. I like the sounds of GS's, but
> >before I blow away my "Active State" version I'd like to know if
> >anyones had any problems with GS's. Also, anyone had problems
> >switching between the versions?
>
> Far and away, Gurusamy's is the best. I had no problems/qualms about
> switching... do yourself and favor and change as soon as you can.
>
Unless you want to work with IIS and CGI/PerlScript/PerlEx/PerlIS, then
stick with AS perl.
Matt (who's looking forward to 5.005).
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 2336
**************************************