[20005] in Perl-Users-Digest
Perl-Users Digest, Issue: 2200 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 25 03:05:48 2001
Date: Sun, 25 Nov 2001 00:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1006675510-v10-i2200@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 25 Nov 2001 Volume: 10 Number: 2200
Today's topics:
Re: A Perl Bug? <uri@stemsystems.com>
Re: A Perl Bug? <joe+usenet@sunstarsys.com>
Re: A Perl Bug? <jake@chaogic.com>
Re: A Perl Bug? <jake@chaogic.com>
Re: A Perl Bug? <joe+usenet@sunstarsys.com>
Re: A Perl Bug? <uri@stemsystems.com>
Re: A Perl Bug? <uri@stemsystems.com>
boards locations. <michealo@ozemail.com.au>
Re: boards locations. <rob_13@excite.com>
Re: Can someone tell me what i am doing wrong. Unix soc <goldbb2@earthlink.net>
Re: can you read a file with out storing it all in memo <rob_13@excite.com>
Re: can you read a file with out storing it all in memo (Jon Bell)
Re: can you read a file with out storing it all in memo (Garry Williams)
Re: can you read a file with out storing it all in memo <michealo@ozemail.com.au>
Re: can you read a file with out storing it all in memo <monty@primenet.com>
Re: can you read a file with out storing it all in memo <Juha.Laiho@iki.fi>
Re: CGI Problem on RedHat 7.1 <admin@bogus.thinktankdecoy.com>
file locking. <michealo@ozemail.com.au>
Re: file problem... <uri@stemsystems.com>
Re: Newbie OO/Inheritance question (Garry Williams)
Perl Documentation <mark@kitfox.com>
Re: Perl Documentation <kevin@vaildc.net>
Re: Perl Programmer Needed to modify shopping cart <dha@panix.com>
Re: question for array operation <michealo@ozemail.com.au>
TESTING CGI SCRIPTS WITH ACTIVE PERL <spamcop@spamcop.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 25 Nov 2001 05:28:01 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: A Perl Bug?
Message-Id: <x7n11ba068.fsf@home.sysarch.com>
>>>>> "JF" == Jake Fan <jake@chaogic.com> writes:
JF> Take a look at this strange problem:
JF> $x[0] = $x[0] || !@x && "x";
that doesn't autovifify $x[0] so you get a value of 'x'
JF> $x[0] ||= !$#x+1 && "x";
that will autovifify $x[0] and then $#x is 0 so the assigned expression
value will be 'x'
JF> $x[0] ||= !@x && "x";
that will autovifify $x[0] and the @x will be 1 so the expression value
is false (undef actually but it will convert to '' when printed).
JF> Supposedly, all three code sections should do the same thing, but
JF> the last one didn't work out as expected. Anyone had the same
JF> experience or know it documented somewhere? I know this may look
JF> trivial, but it is still an undesired "feature by design" (read:
JF> bug).
supposedly is wrong. don't play games with assigment ops and also having
the array on the right side too. perl doesn't define the order of
execution and your code examples are too wierd to even care about.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 25 Nov 2001 01:17:53 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: A Perl Bug?
Message-Id: <m3bshr74ry.fsf@mumonkan.sunstarsys.com>
"Jake Fan" <jake@chaogic.com> writes:
> Take a look at this strange problem:
>
> ########################################
[...]
> $x[0] = $x[0] || !@x && "x";
or slightly more clearly,
$x[0] = $x[0] || ( !@x && "x" );
> print "$x[0]\n";
> undef @x;
>
> $x[0] ||= !$#x+1 && "x";
^^^^^^
Not sure, but ITYM !($#x+1) here.
> print "$x[0]\n";
> undef @x;
>
> $x[0] ||= !@x && "x";
> print "$x[0]\n";
> undef @x;
>
> ########################################
>
> Supposedly, all three code sections should do the same thing, but the
> last one didn't work out as expected.
Actually the last two sections behave identically. I'm pretty sure
that when you write something like
my @x;
$x[0] ||= ...
perl extends the array @x *before* it evaluates the RHS of the ||=.
I'm pretty sure this sort of thing happens for all of the "operator ="
assignments.
It boils down to an "order of evaluation" issue, so it's probably
just more "bad style" :). However, I note that perl emits no warnings
about this, whereas something like lclint *does* catch similar errors
in C. Perhaps another issue for B::Lint to address?
Actually, in this case I'd rather see perl itself emit a warning
about dependence on code that relies on unspecified "order of
evaluation". I suspect that such constructs are in much wider
usage than one might hope.
--
sub TIESCALAR {bless \$_[1]} sub STORE {${$_[0]}=$_[1]}$,=" ";$\=$/;$#Just=1;
tie $left,'main',-4; sub FETCH{${$_[0]}<0?${$_[0]}:$#[${$_[0]}++%4]}$Just[0]=
sub{$left,"\l$#[-++$_[0]]",$left&&$left.","}; @#=qw/Just Another Perl hacker/
;print ++$left, @{++$left} [$left++] -> ($left++) # some words on play
------------------------------
Date: Sun, 25 Nov 2001 00:33:23 -0600
From: "Jake Fan" <jake@chaogic.com>
Subject: Re: A Perl Bug?
Message-Id: <9tq3c6$6cm$1@Masala.CC.UH.EDU>
Thanks for the quick reply. It's quite informative. Most of my Perl
knowledge comes from the manpage (perldoc.com) and hands-on experiences. As
far as I remember there is not much info about the "autovivify" concept in
the manpage. Can you recommend additional reading material (or maybe the
proper manpage I missed) before I hit Google?
The code snippet was for illustration purposes only. It may not be so weird
in real life as I encountered the problem in a real world application. I
think the problem is a bit counter-intuitive, for people with little
knowledge of the internals of Perl. Considering "&&" takes precedence over
"+=, .=, ||=" etc, the result of "$x[0] ||= !@x && 'x';" doesn't seem
ambiguous -- until "autovivify" kicks in, that is.
Anyhow, thanks again for the tip.
p.s. It's "autovivify" (instead of "autovifify"), I assume?
Uri Guttman <uri@stemsystems.com> wrote in message
news:x7n11ba068.fsf@home.sysarch.com...
> >>>>> "JF" == Jake Fan <jake@chaogic.com> writes:
>
> JF> Take a look at this strange problem:
>
> JF> $x[0] = $x[0] || !@x && "x";
>
> that doesn't autovifify $x[0] so you get a value of 'x'
>
> JF> $x[0] ||= !$#x+1 && "x";
>
> that will autovifify $x[0] and then $#x is 0 so the assigned expression
> value will be 'x'
>
> JF> $x[0] ||= !@x && "x";
>
> that will autovifify $x[0] and the @x will be 1 so the expression value
> is false (undef actually but it will convert to '' when printed).
>
> JF> Supposedly, all three code sections should do the same thing, but
> JF> the last one didn't work out as expected. Anyone had the same
> JF> experience or know it documented somewhere? I know this may look
> JF> trivial, but it is still an undesired "feature by design" (read:
> JF> bug).
>
> supposedly is wrong. don't play games with assigment ops and also having
> the array on the right side too. perl doesn't define the order of
> execution and your code examples are too wierd to even care about.
>
> uri
>
> --
> Uri Guttman ------ uri@stemsystems.com --------
http://www.stemsystems.com
> -- Stem is an Open Source Network Development Toolkit and Application
Suite -
> ----- Stem and Perl Development, Systems Architecture, Design and
Coding ----
> Search or Offer Perl Jobs ----------------------------
http://jobs.perl.org
------------------------------
Date: Sun, 25 Nov 2001 00:50:09 -0600
From: "Jake Fan" <jake@chaogic.com>
Subject: Re: A Perl Bug?
Message-Id: <9tq4bg$6dq$1@Masala.CC.UH.EDU>
Yep, you are right, it's supposed to be !($#x+1).
Joe Schaefer <joe+usenet@sunstarsys.com> wrote in message
news:m3bshr74ry.fsf@mumonkan.sunstarsys.com...
> "Jake Fan" <jake@chaogic.com> writes:
>
> > Take a look at this strange problem:
> >
> > ########################################
>
> [...]
>
> > $x[0] = $x[0] || !@x && "x";
>
> or slightly more clearly,
>
> $x[0] = $x[0] || ( !@x && "x" );
>
> > print "$x[0]\n";
> > undef @x;
> >
> > $x[0] ||= !$#x+1 && "x";
> ^^^^^^
>
> Not sure, but ITYM !($#x+1) here.
>
> > print "$x[0]\n";
> > undef @x;
> >
> > $x[0] ||= !@x && "x";
> > print "$x[0]\n";
> > undef @x;
> >
> > ########################################
> >
> > Supposedly, all three code sections should do the same thing, but the
> > last one didn't work out as expected.
>
> Actually the last two sections behave identically. I'm pretty sure
> that when you write something like
>
> my @x;
>
> $x[0] ||= ...
>
> perl extends the array @x *before* it evaluates the RHS of the ||=.
> I'm pretty sure this sort of thing happens for all of the "operator ="
> assignments.
>
> It boils down to an "order of evaluation" issue, so it's probably
> just more "bad style" :). However, I note that perl emits no warnings
> about this, whereas something like lclint *does* catch similar errors
> in C. Perhaps another issue for B::Lint to address?
>
> Actually, in this case I'd rather see perl itself emit a warning
> about dependence on code that relies on unspecified "order of
> evaluation". I suspect that such constructs are in much wider
> usage than one might hope.
>
> --
> sub TIESCALAR {bless \$_[1]} sub STORE {${$_[0]}=$_[1]}$,="
";$\=$/;$#Just=1;
> tie $left,'main',-4; sub
FETCH{${$_[0]}<0?${$_[0]}:$#[${$_[0]}++%4]}$Just[0]=
> sub{$left,"\l$#[-++$_[0]]",$left&&$left.","}; @#=qw/Just Another Perl
hacker/
> ;print ++$left, @{++$left} [$left++] -> ($left++) # some words on
play
>
------------------------------
Date: 25 Nov 2001 01:54:37 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: A Perl Bug?
Message-Id: <m37ksf732q.fsf@mumonkan.sunstarsys.com>
Uri Guttman <uri@stemsystems.com> writes:
> >>>>> "JF" == Jake Fan <jake@chaogic.com> writes:
[...]
> JF> $x[0] ||= !@x && "x";
>
> that will autovifify $x[0] and the @x will be 1 so the expression value
> is false (undef actually but it will convert to '' when printed).
Nitpick- !1 (and hence $x[0]) really *is* ''; no conversion
necessary (and none would take place w/o warning :)
% perl -wle 'print defined !1'
1
--
Joe Schaefer "I don't give a damn for a man that can only spell a word one
way."
--Mark Twain
------------------------------
Date: Sun, 25 Nov 2001 07:01:23 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: A Perl Bug?
Message-Id: <x7itbz9vul.fsf@home.sysarch.com>
>>>>> "JF" == Jake Fan <jake@chaogic.com> writes:
please don't top post. read these pages:
http://www.btinternet.com/~chiba/sbox/topposters.html
http://www.uwasa.fi/~ts/http/quote.html
http://www.geocities.com/nnqweb/nquote.html
JF> Thanks for the quick reply. It's quite informative. Most of my
JF> Perl knowledge comes from the manpage (perldoc.com) and hands-on
JF> experiences. As far as I remember there is not much info about
JF> the "autovivify" concept in the manpage. Can you recommend
JF> additional reading material (or maybe the proper manpage I missed)
JF> before I hit Google?
get a good book or two. and read the perl FAQ. and reread the perl docs
over and cross read them. when reading one section and it refers to
something elsewhere, read that.
read my autovivify tutorial at:
http://tlc.perlarchive.com/articles/perl/ug0002.shtml
JF> The code snippet was for illustration purposes only. It may not
JF> be so weird in real life as I encountered the problem in a real
JF> world application. I think the problem is a bit
JF> counter-intuitive, for people with little knowledge of the
JF> internals of Perl. Considering "&&" takes precedence over "+=,
JF> .=, ||=" etc, the result of "$x[0] ||= !@x && 'x';" doesn't seem
JF> ambiguous -- until "autovivify" kicks in, that is.
that is the hidden issue. you can't assign to $x[0] unless it is created
first. then @x will be 1. remember ||= knows it will assign something to
@x so it wants to allocate the element slot first for speed. there is
no defined order that says the right side of = will be fully evaluated
before the assignment.
JF> p.s. It's "autovivify" (instead of "autovifify"), I assume?
yes, a typo.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 25 Nov 2001 07:06:36 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: A Perl Bug?
Message-Id: <x7g0739vlw.fsf@home.sysarch.com>
>>>>> "JS" == Joe Schaefer <joe+usenet@sunstarsys.com> writes:
JS> Uri Guttman <uri@stemsystems.com> writes:
>> >>>>> "JF" == Jake Fan <jake@chaogic.com> writes:
JS> [...]
JF> $x[0] ||= !@x && "x";
>>
>> that will autovifify $x[0] and the @x will be 1 so the expression value
>> is false (undef actually but it will convert to '' when printed).
JS> Nitpick- !1 (and hence $x[0]) really *is* ''; no conversion
JS> necessary (and none would take place w/o warning :)
JS> % perl -wle 'print defined !1'
JS> 1
true.
tidbit back:
the perl boolean false value is very unusual. it is both 0 and '' and
can be used in string or numeric expressions without warnings unlike
undef.
perl -lwe '$x = !1 ; print $x + 1'
1
perl -lwe '$x = undef ; print $x + 1'
Use of uninitialized value at -e line 1.
1
perl -lwe '$x = !1 ; print "[$x]"'
[]
perl -lwe '$x = undef ; print "[$x]"'
Use of uninitialized value at -e line 1.
[]
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 25 Nov 2001 17:12:59 +1100
From: "nathan" <michealo@ozemail.com.au>
Subject: boards locations.
Message-Id: <8V%L7.18549$li3.208509@ozemail.com.au>
can any one give me the location to some php and coldfusion boards like this
perl one.?
------------------------------
Date: Sun, 25 Nov 2001 06:55:53 GMT
From: "Rob - Rock13.com" <rob_13@excite.com>
Subject: Re: boards locations.
Message-Id: <Xns9164136D6D9EBrock13com@64.8.1.227>
nathan <news:8V%L7.18549$li3.208509@ozemail.com.au>:
> can any one give me the location to some php and coldfusion
> boards like this perl one.?
This ain't a board, this is Usenet. So use your newsreader to look
for groups with php or coldfusion in their names. Might want to
stop at groups.google.com as well.
My news server is showing me an alt.php and alt.comp.lang.php also
a alt.comp.lang.coldfusion.
I don't see anything in the comp.infosystems.www.* hierarchy where
the groups might be considered better established.
Additionally, the folks who make PHP and coldfusion may have
mailing lists, boards, or news groups (on their own news servers)
as well.
--
Rob - http://rock13.com/
Web Stuff: http://rock13.com/webhelp/
------------------------------
Date: Sun, 25 Nov 2001 00:19:09 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Can someone tell me what i am doing wrong. Unix sockets
Message-Id: <3C007F4D.42658CBA@earthlink.net>
Scott wrote:
>
> I am trying to get the below code to print out the data sent to the
> listening port and send a response back to the browser but I can get
> the damn thing working
>
> I open up a listening socket here on port 80 and then this code. It
> listens and prints out the where the connection came from bit but I
> can't get it to print the HTTP 1.0 GET request that the browser should
> have sent, nor can I get the printing to the client stream to work so
> the browser reports a 404.
[snip]
> Any help or pointers as to what i'm doing wrong mucho appreciated.
> Scott
What you're doing mucho wrong is trying to code it yourself, when
modules exist for this very problem.
perldoc HTTP::Daemon
And if you don't have it [it's part of the libwww-perl bundle], get it
from CPAN.
--
Klein bottle for rent - inquire within.
------------------------------
Date: Sun, 25 Nov 2001 05:30:39 GMT
From: "Rob - Rock13.com" <rob_13@excite.com>
Subject: Re: can you read a file with out storing it all in memorey?
Message-Id: <Xns91644F96E5A0rock13com@64.8.1.227>
nathan <news:_L_L7.18507$li3.205594@ozemail.com.au>:
> i was wondering if you can read all of a file line by line with
> out storing it in memorey ?
Yes, you can.
e.g. $line = <FILE>;
as opposed to @lines = <FILE>;
--
Rob - http://rock13.com/
Web Stuff: http://rock13.com/webhelp/
------------------------------
Date: Sun, 25 Nov 2001 05:10:44 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: can you read a file with out storing it all in memorey?
Message-Id: <GnCBpx.3oy@presby.edu>
In article <_L_L7.18507$li3.205594@ozemail.com.au>,
nathan <michealo@ozemail.com.au> wrote:
>i was wondering if you can read all of a file line by line with out storing
>it in memorey ?
open (INPUT, "input.dat") or die "Can't open input.dat!\n";
while (my $Line = <INPUT>)
{
# do something with $Line
}
close INPUT;
--
Jon Bell <jtbell@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
------------------------------
Date: Sun, 25 Nov 2001 05:53:16 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: can you read a file with out storing it all in memorey?
Message-Id: <slrna011qj.e20.garry@zfw.zvolve.net>
On Sun, 25 Nov 2001 15:26:51 +1100, nathan <michealo@ozemail.com.au> wrote:
> i was wondering if you can read all of a file line by line with out storing
> it in memorey ?
Yes.
while (<FH>) { ... }
See the perlsyn manual page about the while statement and the perlop
manual page about I/O Operators.
--
Garry Williams
------------------------------
Date: Sun, 25 Nov 2001 17:15:45 +1100
From: "nathan" <michealo@ozemail.com.au>
Subject: Re: can you read a file with out storing it all in memorey?
Message-Id: <zY%L7.18551$li3.208716@ozemail.com.au>
thanks. i have perl cook book but it's so long and besides i only just got
it.
i have been using
@arrey=<handle>;
but i realy needed a beater method , becouse my database might get fairly
big at some point/
Garry Williams <garry@ifr.zvolve.net> wrote in message
news:slrna011qj.e20.garry@zfw.zvolve.net...
> On Sun, 25 Nov 2001 15:26:51 +1100, nathan <michealo@ozemail.com.au>
wrote:
> > i was wondering if you can read all of a file line by line with out
storing
> > it in memorey ?
>
> Yes.
>
> while (<FH>) { ... }
>
> See the perlsyn manual page about the while statement and the perlop
> manual page about I/O Operators.
>
> --
> Garry Williams
------------------------------
Date: Sun, 25 Nov 2001 06:31:30 +0000 (UTC)
From: Jim Monty <monty@primenet.com>
Subject: Re: can you read a file with out storing it all in memorey?
Message-Id: <1006669910.703415@nnrp1.phx1.gblx.net>
nathan <michealo@ozemail.com.au> wrote:
> i was wondering if you can read all of a file line by line with out
> storing it in memorey ?
Of course.
perl -n
perl -p
For example,
perl -n /dev/null <file ...> # read file(s) silently, purposelessly
perl -p /dev/null <file ...> # emulate cat optionlessly
--
Jim Monty
monty@primenet.com
Tempe, Arizona USA
------------------------------
Date: Sun, 25 Nov 2001 07:51:01 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: can you read a file with out storing it all in memorey?
Message-Id: <9tq7op$skd$1@ichaos.ichaos-int>
"nathan" <michealo@ozemail.com.au> said:
>but i realy needed a beater method , becouse my database might get fairly
>big at some point/
If it's a database, consider using a database interface instead of rolling
your own on top of plain text. Especially if you expet a lot of data on
which you'll do key-based search.
"perldoc" documentation can be found for one or more of
- DB_File
- DBM_File
- SDBM_File
depending on your OS platform and perl compilation.
Then there are also interfaces to "big" relational SQL databases.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ UH++++$ UL++++$ P++@ L+++ E(-) W+$@ N++ !K w !O
!M V PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h--- r+++ y+++
"...cancel my subscription to the resurrection!" (Jim Morrison)
------------------------------
Date: Sat, 24 Nov 2001 23:54:25 -0500
From: "$uRoot" <admin@bogus.thinktankdecoy.com>
Subject: Re: CGI Problem on RedHat 7.1
Message-Id: <9tpten0fot@enews2.newsguy.com>
"$uRoot" <admin@bogus.thinktankdecoy.com> wrote in message
news:9tojch015ea@enews3.newsguy.com...
> Hi. I don't do a lot of work with CGI, so was wondering if anyone knew
what
> the problem might be here.
>
Thanks for the replies, folks (even if this was off topic).
The copy of perl on this machine must have gotten mucked up somewhere along
the line. I ended up downloading & recompiling it from source & now the
script works fine.
Thanks again.
------------------------------
Date: Sun, 25 Nov 2001 17:21:39 +1100
From: "nathan" <michealo@ozemail.com.au>
Subject: file locking.
Message-Id: <810M7.18554$li3.208922@ozemail.com.au>
can some one explain file locking to me.
i know that there are 3 or 4 settings
and how can you find what the server type is .
ie / windows 9x, linux, windows 2000 , windows xp?
------------------------------
Date: Sun, 25 Nov 2001 05:12:07 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: file problem...
Message-Id: <x7r8qna0wq.fsf@home.sysarch.com>
>>>>> "BL" == Bart Lateur <bart.lateur@pandora.be> writes:
BL> Uri Guttman wrote:
M> foreach (@members) {
M> print "\'$_\'\n";
M> }
>>
>> no need for the \. the whole point of using different quote chars is so
>> you don't have to escape the other quote chars.
BL> Er, no. The point of having both '"' and "'" as quote characters is that
BL> both have a different behaviour: double quotes allow interpolation,
BL> while everything between single quotes, apart from backslashes in front
BL> of backslashes and single quotes, are taken as is (yes, even '\n').
duh!
actually what annoys me in newbie code are debug prints with "" around
the var's value so they escape them like:
print "\$var = \"$var\"\n" ;
which is fugly.
my point above which wasn't fleshed out is when marking internal
strings, then using '' inside of "" is very clean. the code i quoted did
that right but still escaped the inside quotes.
another peave is why they need the $ in the string causing another
escape. i just use the name by itself. i know it is a scalar.
print "var = '$var'\n" ;
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 25 Nov 2001 07:02:41 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Newbie OO/Inheritance question
Message-Id: <slrna015so.e20.garry@zfw.zvolve.net>
On Sat, 24 Nov 2001 20:44:05 -0000, Dave Carmean <dlc-usenet@halibut.com> wrote:
>
> So I think I understand (generally) inheritance by a child class.
> What about existing objects? E.g. say I'm tracking "tickets" of various
> kinds. I have a superclass called Ticket which has basic stuff like
> reporting party, date and time reported, description, etc., etc.
>
> At some point the issue is narrowed down sufficiently that it's appropriate
> to use several additional fields. E.g. it's determined to be a hardware
> problem rather than software, so we need to start tracking serial numbers,
> etc. How do I turn the existing Ticket object into a Ticket::Hardware
> object? Do I write Ticket::Hardware::new such that if it's handed a
> Ticket object it re-blesses it as type Ticket::Hardware? And then
> I start adding new attributes to the inherited hash (or whatever)?
[ I assume you know that the package name (Ticket::Hardware) has
nothing to do with the object's inheritance hierarchy. ]
package Ticket::Hardware;
use strict;
use vars '@ISA';
use Ticket;
@ISA = ('Ticket');
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self;
if ( $class eq __PACKAGE__ ) {
$self = $class->SUPER::new();
}
else {
$self = bless($proto, __PACKAGE__);
}
# ... (add Ticket::Hardware attributes to $self)
$self;
}
Call the new() method as a class constructor (Ticket::Hardware->new())
to get a new Ticket::Hardware object or with a Ticket object to get it
re bless()ed as a Ticket::Hardware object. This assumes that Ticket
uses the two argument form of bless().
Read the perltoot manual page and in particular, the "Inheritance"
section.
> What if I'm keeping class data like the total number of base Ticket
> objects that haven't been morphed into more specialized types? Does
> DESTROY get called when it gets reblessed?
Huh? DESTROY() isn't called by bless(). bless() has no effect on
class data.
See perlfunc (bless()).
--
Garry Williams
------------------------------
Date: Sun, 25 Nov 2001 01:42:04 -0500
From: Mark McKay <mark@kitfox.com>
Subject: Perl Documentation
Message-Id: <3C0092BC.C07BCF19@kitfox.com>
Hi. I'm wondering if anyone could point me to a good source of Perl
documentation. I've read the online FAQ, and a lot of people have
pointed me to cpan.org and perdoc.com, but aside from documentation of
Perl modules (which is very good), I'm having trouble finding stuff.
Does anyone have a link to an index similar to what you'd find in the
back of the Camel book?
Mark McKay
--
We, in all humidity, are the people of currant times. This
concept grinds our critical, seething minds to a halt.
- Anders Henriksson, "A History of the Past, Part II"
(A collection of excerpts from student papers)
------------------------------
Date: Sun, 25 Nov 2001 02:03:14 -0500
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: Perl Documentation
Message-Id: <251120010203144660%kevin@vaildc.net>
In article <3C0092BC.C07BCF19@kitfox.com>, Mark McKay <mark@kitfox.com>
wrote:
> Hi. I'm wondering if anyone could point me to a good source of Perl
> documentation. I've read the online FAQ, and a lot of people have
> pointed me to cpan.org and perdoc.com, but aside from documentation of
> Perl modules (which is very good), I'm having trouble finding stuff.
> Does anyone have a link to an index similar to what you'd find in the
> back of the Camel book?
Perl comes with *lots* of documentation and a program called "perldoc"
to display it. Use "perldoc -f" to get information about a particular
Perl function, "perldoc -q" to get information about a particular FAQ
keyword, or "perldoc perldoc" to get more information about perldoc.
It's all there, somewhere, already installed on your system.
--
Kevin Michael Vail | a billion stars go spinning through the night,
kevin@vaildc.net | blazing high above your head.
. . . . . . . . . | But _in_ you is the presence that
. . . . . . . . . | will be, when all the stars are dead. (Rainer Maria Rilke)
------------------------------
Date: 25 Nov 2001 07:11:02 GMT
From: "David H. Adler" <dha@panix.com>
Subject: Re: Perl Programmer Needed to modify shopping cart
Message-Id: <slrna016c6.f1m.dha@panix2.panix.com>
In article <495321b5.0111240001.e27a47f@posting.google.com>, Gary wrote:
> Please review the folling perl program and provide an estimate for
> your services by sending me an e-mail at
[snip]
You have posted a job posting or a resume in a technical group.
Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.
Had you read and understood the Usenet user manual posted frequently to
"news.announce.newusers", you might have already known this. :) (If
n.a.n is quieter than it should be, the relevent FAQs are available at
http://www.faqs.org/faqs/by-newsgroup/news/news.announce.newusers.html)
Another good source of information on how Usenet functions is
news.newusers.questions (information from which is also available at
http://www.geocities.com/nnqweb/).
Please do not explain your posting by saying "but I saw other job
postings here". Just because one person jumps off a bridge, doesn't
mean everyone does. Those postings are also in error, and I've
probably already notified them as well.
If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.
http://jobs.perl.org may be of more use to you
Also, posting all that code for no good reason wasn't such a great idea
either...
Yours for a better usenet,
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"Well, anyone can talk sense..." - The Doctor (4th)
------------------------------
Date: Sun, 25 Nov 2001 17:29:43 +1100
From: "nathan" <michealo@ozemail.com.au>
Subject: Re: question for array operation
Message-Id: <D80M7.18557$li3.209238@ozemail.com.au>
isnt there some kind of pop function?
Kit <hkyeung9@ie.cuhk.edu.hk> wrote in message
news:9to2ph$kr9$1@eng-ser1.erg.cuhk.edu.hk...
> Thx~ But is it apply to hash only?
> "Laocoon" <Laocoon@eudoramail.com> wrote in message
> news:Xns916384A54DC18Laocooneudoramailcom@62.153.159.134...
> > perldoc -f delete
>
>
------------------------------
Date: Sun, 25 Nov 2001 02:01:36 -0500
From: "cb" <spamcop@spamcop.net>
Subject: TESTING CGI SCRIPTS WITH ACTIVE PERL
Message-Id: <nI0M7.1$407.174@typhoon.nyu.edu>
I haven't used Active Perl in a while and completely forgot on how to use
it. If I want to write CGI script and test it with a server in what
directory do I put my html and pl files and what else do I have to do to
test it?
thanx guys
--
tosspam@aol.com abuse@aol.com abuse@yahoo.com abuse@hotmail.com
abuse@msn.com abuse@sprint.com abuse@earthlink.com uce@ftc.gov
spamcop@spamcop.net
------------------------------
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 2200
***************************************