[11441] in Perl-Users-Digest
Perl-Users Digest, Issue: 5041 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 3 06:07:23 1999
Date: Wed, 3 Mar 99 03:00:24 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 3 Mar 1999 Volume: 8 Number: 5041
Today's topics:
Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Pos (Abigail)
Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Pos (Ronald J Kimball)
Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Pos <Philip.Newton@datenrevision.de>
Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Pos (Jonathan Stowe)
Re: A smiple question (Ronald J Kimball)
Re: A smiple question <coyote38@pacbell.net>
Re: cgi question (Ronald J Kimball)
Re: Cookies in IE3... <dgris@moiraine.dimensional.com>
Re: Cookies in IE3... <pejama@jane.math.jyu.fi>
Re: Finding the word after a word <udaa460@axolotl.kcl.ac.uk>
Re: Help choose a book! (Tad McClellan)
help on APPLET Class <liu@bommerang.aero.rmit.edu.au>
Re: Help with hash references (Steve Grantz)
Re: How does one 'tie' a db file to a hash' (Ronald J Kimball)
Re: How does one 'tie' a db file to a hash' (Ilya Zakharevich)
Re: HTML parse problem (Earl Hood)
Re: MAIL file attachements ? (Abigail)
Matching and replacing patterns.. <c.m.oudeman@st.hanze.nl>
Re: Merge 2 Password Files <morrowc@his.com>
Re: method overriden! (Abigail)
Re: method overriden! <zenin@bawdycaste.org>
Re: method overriden! (Ronald J Kimball)
Re: method overriden! <ekkis@arix.com>
Re: method overriden! <ekkis@arix.com>
module for 'get' command? <hilljere@msu.edu>
Need Help with Regular expressions <nima.m@lyckseleNOSPAM.net>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 3 Mar 1999 04:56:39 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice Weekly ***
Message-Id: <7bife7$2en$1@client2.news.psi.net>
Ronald J Kimball (rjk@linguist.dartmouth.edu) wrote on MMX September
MCMXCIII in <URL:news:1do2799.dvk4pb1as2dmmN@bay1-134.quincy.ziplink.net>:
**
** You know, you don't have to read the auto-FAQ every time it's posted...
Who are you telling me what to read?
Abigail
--
perl -wlpe '}{$_=$.' file # Count the number of lines.
------------------------------
Date: Tue, 2 Mar 1999 23:17:53 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice Weekly ***
Message-Id: <1do2799.dvk4pb1as2dmmN@bay1-134.quincy.ziplink.net>
Andrew Fry <andrewf@beausys.demon.co.uk> wrote:
> My point
> is simply that I find it irritating and patronizing to be constatntly
> told what I should be reading.
You know, you don't have to read the auto-FAQ every time it's posted...
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Wed, 03 Mar 1999 11:33:47 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice Weekly ***
Message-Id: <36DD100B.B21B8AFC@datenrevision.de>
Abigail wrote:
>
> Ronald J Kimball (rjk@linguist.dartmouth.edu) wrote on MMX September
> MCMXCIII in <URL:news:1do2799.dvk4pb1as2dmmN@bay1-134.quincy.ziplink.net>:
[...]
Abigail, where are you getting those dates from? MMX September MCMCXIII,
indeed!
Vale,
Philip
------------------------------
Date: Wed, 03 Mar 1999 10:11:23 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice Weekly ***
Message-Id: <36dd0a20.5201584@news.dircon.co.uk>
On Tue, 2 Mar 1999 23:17:54 -0500, rjk@linguist.dartmouth.edu (Ronald
J Kimball) wrote:
>Jonathan Stowe <gellyfish@btinternet.com> wrote:
>
>>
>> <http://x7.dejanews.com/[ST_rn=ps]/dnquery.xp?
> search=next&DBS=1&LNG=ALL&IS=&svcclass=dnserver&
> ST=PS&offsets=&svcclass=dnserver&CONTEXT=920367858.58458407>
>>
>[Sorry, had to wrap the URL to post.]
>
>
>I get the following with the above URL:
>
> Unknown Error
>
> The system encountered an unknown error: Your search didn't
> work because:
>
> query is null
>
>
>I think you forgot to 'View for Bookmarking' before capturing the URL.
>
Unfortunately it was a search result page - shall we try:
<http://x3.dejanews.com/[ST_rn=ps]/dnquery.xp?ST=PS&QRY=*&defaultOp=AND&DBS=1&showsort=score&maxhits=25&LNG=ALL&subjects=comp.lang.perl.misc&groups=alt.humor.best-of-usenet&authors=&fromdate=&todate=&format=terse>
You dont get view for bookmarking on that page I'm afraid.
/j\
------------------------------
Date: Tue, 2 Mar 1999 23:17:55 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: A smiple question
Message-Id: <1do27g0.35yslrffrhr2N@bay1-134.quincy.ziplink.net>
Jerome O'Neil <jeromeo@atrieva.com> wrote:
> Try these (all untested, right OTTOMH.)
>
I know what untested means. What does OTTOMH mean?
> if $foo !~ /\d+/; # If $foo is not all digits, all the time.
>
You forgot to anchor the regex.
/^\d+$/
> if $foo =~ /\D+/; # If foo contains any non-digit character.
Any non-digit character; one is enough.
/\D/;
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
perl -e'$_="\012534`!./4(%2`\cp%2,`(!#+%2j";s/./"\"\\c$&\""/gees;print'
------------------------------
Date: Tue, 2 Mar 1999 23:05:30 -0800
From: "coyote38" <coyote38@pacbell.net>
Subject: Re: A smiple question
Message-Id: <Yb5D2.7070$8N5.75110@typhoon-sf.pbi.net>
This works:
if($foo =~ /\D/)
{
print "$foo contains a non-numeric character\n";
}
You can do the same by not-matching:
if($foo !~ /\D/)
{
print "$foo contains only numeric characters\n";
}
coyote38@pacbell.net
Dong Tang wrote in message ...
>How do I detect if a string has any non-numeric character in it by using
>regular expression, but code below doesn't work.
>$foo = "3w43242";
>if ($foo =~ /![0-9]/)
>{
> print "$foo has non-numeric charater.\n"
>}
>
>
>I am a Perl newbie, so you know the answer, could you email at
>tangd@ctcdist.com
>
>
>Thanx
>
>Don Tang
>
>
------------------------------
Date: Tue, 2 Mar 1999 23:17:56 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: cgi question
Message-Id: <1do27ma.hrtsik1mwoo5pN@bay1-134.quincy.ziplink.net>
Justin Baugh <baughj@rpi.edu> wrote:
> Actually, the error was a lot stupider than that. I forgot that I
> was having the CGI output stylesheets, and in one version of the
> script I changed the global variable $location to $stylesheet, but
> forgot to change it in one area. Strangely enough...even with -w
> on, Perl didn't yell about using a undefined.
Did you check the CGI server's error logs? That's where the warning(s)
would show up.
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 03 Mar 1999 03:01:34 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Cookies in IE3...
Message-Id: <m3vhgi3n9d.fsf@moiraine.dimensional.com>
Pertti Maki-Valkkila <pejama@jane.math.jyu.fi> writes:
> I am
> really really REALLY sorry I asked this stupid question. I'll just
> lay down and shoot my self.
Thank you. Please be careful to not make too much of a mess of
the rug (put down a plastic sheet, or something).
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: 3 Mar 1999 06:50:49 GMT
From: Pertti Maki-Valkkila <pejama@jane.math.jyu.fi>
Subject: Re: Cookies in IE3...
Message-Id: <7bim49$jj2$1@mordred.cc.jyu.fi>
Abigail <abigail@fnx.com> wrote:
> Pertti Maki-Valkkila (pejama@jane.math.jyu.fi) wrote on MMIX September
> MCMXCIII in <URL:news:7bggat$hel$1@mordred.cc.jyu.fi>:
> ||
> || I'm working on a project that uses cookies to identify different users. I've
> || come across with a problem when setting cookies in IE3. It seems that the
> || structure of a cookie is different in version 3 than it is in IE4 (or NN3/4).
> And your problem is a Perl problem because?
Because this was the only reasonable place I thought I could get help for my
problem. I thought you might have come across with this subject but I guess
you've never done anything that has cookies involved with. I am really
really REALLY sorry I asked this stupid question. I'll just lay down and shoot
my self.
Pertti M-V
> Abigail
> --
> perl -wleprint -eqq-@{[ -eqw\\\\- -eJust -eanother -ePerl -eHacker -e\\\\-]}-
------------------------------
Date: 3 Mar 1999 10:33:53 GMT
From: Allan Hawdon <udaa460@axolotl.kcl.ac.uk>
Subject: Re: Finding the word after a word
Message-Id: <7bj36h$kp0$1@willow.cc.kcl.ac.uk>
Staffan Liljas <staffan@ngb.se> wrote:
: Allan Hawdon wrote:
:> Allan Hawdon <udaa460@axolotl.kcl.ac.uk> wrote:
:> : Allan Hawdon <udaa460@axolotl.kcl.ac.uk> wrote:
:> : : kalikste@uiuc.edu wrote:
:> : : : Quick question for a regular expression-
:>
:> <snip>
:>
:> : Whoops. Unless it's at the beginning of the string of course.
:>
:> : ($dummy,$res) = $string =~ /(^|.* )$srch (\S+) /;
: what kind of word is (\S+)? why not use
: $string =~ /\b$srch (\w+)\b/;
: $word =~ $1;
I just didn't want to assume that the original poster meant the same
thing by "word" as is meant by the strict technical definition in
perl regexps.
------------------------------
Date: Tue, 2 Mar 1999 17:48:20 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help choose a book!
Message-Id: <krphb7.ls1.ln@magna.metronet.com>
Harris Mahedavi (mahedavi@prodigy.net) wrote:
: Can some one suggest a good Perl5 book for web development book.
Perl FAQ, part 2:
"Perl Books"
Perl FAQ, part 3:
"Where can I learn about CGI or Web programming in Perl?"
http://language.perl.com/critiques/index.html
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 03 Mar 1999 18:16:25 +1100
From: lql <liu@bommerang.aero.rmit.edu.au>
Subject: help on APPLET Class
Message-Id: <36DCE1C9.CF5E3E51@bommerang.aero.rmit.edu.au>
Hi, My friends,
I am a now stuying the Javascript. But I just don't understand what
does the ***.class mean, and how it could be produced. If someone could
be
of any help, Please send me some information about it or tell me where
could I find some good tutorials about it.
With best regards
Thanks
------------------------------
Date: Wed, 03 Mar 1999 09:50:46 GMT
From: sgrantz@visi.com (Steve Grantz)
Subject: Re: Help with hash references
Message-Id: <WB7D2.516$66.25154@ptah.visi.com>
Paul M. Neth (pdafnedd@adfasdge.com) wrote:
: I am working on the following perl script.
[much code snipped]
: %raws=($yymmddhh,$rh);
Using this statement to populate the hash will result in the entire hash
being recreated each time through the loop.
Try assigining the individual members instead by
$raws{$yymmddhh} = $rh;
Hope this helps,
Steve
--
More of Steve Grantz's Blather at 2 * McQ != McQ
http://www.visi.com/~sgrantz 0.5 * McQ == McQ
------------------------------
Date: Tue, 2 Mar 1999 23:17:57 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: How does one 'tie' a db file to a hash'
Message-Id: <1do290b.1q40qiefwqs38N@bay1-134.quincy.ziplink.net>
[Please don't send stealth CCs.]
J. Daniel Paxton wrote:
>
> I have rewritten the line using DB_File:
>
> my $timesleft=tie %timesleft, "DB_File", "users.db", O_RDWR|O_CREAT, 0644,
> $DB_HASH or
> die "Unable to open or create timesleft: $!" unless defined $timesleft;
>
That logic doesn't make sense.
(my $timesleft = tie() or die "$!") unless defined $timesleft;
You just declared $timesleft, so it can't be defined yet. But you test
it
for definedness before initializing it.
I don't think the 'unless defined $timesleft' serves any purpose there.
> and now have acquired a new error message:
>
> Unable to open or create timesleft: Inappropriate file type or format at
> WPS2.cgi line 30.
>
> Why ?
>
What happens if you change that to:
my $timesleft =
tie %timesleft, "DB_File", "users", O_RDWR|O_CREAT, 0644, $DB_HASH;
^^^^^^^
?
I think the .db extension is added for you during the tie process.
--
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
perl -s -e'print sort grep { /\s/ } keys %main::
' -- -is -' Just' -' another ' -'Perl ' -'hacker
' http://www.ziplink.net/~rjk/ [rjk@linguist.dartmouth.edu]
------------------------------
Date: 3 Mar 1999 06:57:41 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: How does one 'tie' a db file to a hash'
Message-Id: <7bimh5$269$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Ronald J Kimball
<rjk@linguist.dartmouth.edu>],
who wrote in article <1do290b.1q40qiefwqs38N@bay1-134.quincy.ziplink.net>:
> (my $timesleft = tie() or die "$!") unless defined $timesleft;
>
> You just declared $timesleft, so it can't be defined yet.
Worse. Two strings '$timesleft' in the above line of code are
resolved to different Perl variables. [Not that it makes the original
code any better. ;-]
[For curious: `my' takes action only *after* the end of statement, so
the '$timesleft' "on the right" is resolved to whatever was in
scope before the `my' declaration, most probably a package
variable. This is why a script without `use strict' and -w is
useless. ]
Ilya
------------------------------
Date: 3 Mar 1999 07:31:22 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: HTML parse problem
Message-Id: <7bioga$t3j@news.service.uci.edu>
In article <uvhgk6oe2.fsf@jimbosntserver.soundimages.co.uk>,
Jim Brewer <jimbo@soundimages.co.uk> wrote:
>Jim Correia <correia@barebones.com> writes:
>
>> Yes indeed. I'd like to see the standards in question that require the
>> quotes (XML doesn't count, since we aren't talking about XML).
>
>The ISO SGML Standards, for a start. The quotes may be omitted when
>the attribute value contains only text characters (also as defined by
>ISO SGML) with no intervening white space. Attribute values which
Not completely accurate. The literal start/end characters (commonly
the quote characters) can be ommitted if the attribute value is
comprised only of NAME characters. Hence, according to the SGML
standard, quotes may need to be used even if there is no whitespace.
For example:
<TABLE WIDTH="100%">
>contain whitespace must be enclosed in quotes. Further, any attribute
>which contains multiple values must also be enclosed in quotes with
>each value seperated by a comma, whether or not whitespace is
>present.
Nope. When it comes to the various attribute value list types
(name list, number list, et al), the SPACE character is used to
separate values.
If you are talking about CDATA attributes, SGML has not concept
of a list for these attributes, so any "list" notation is up to
the application.
>Further, standards are standards. HTML and XML are both SGML
>applications.
Wrong (you need to some reading up).
HTML can be expressed as an SGML application.
XML is a formal subset of SGML.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: 3 Mar 1999 04:58:22 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: MAIL file attachements ?
Message-Id: <7bifhe$2en$2@client2.news.psi.net>
WebMaster (WebMaster@beatcity.co.uk) wrote on MMIX September MCMXCIII in
<URL:news:36DB88A8.7D37DBAC@beatcity.co.uk>:
$$
$$ I would like to email a FILE attachement such as a ZIP or TXT or even
$$ JPG file directly from my server and obviously want it to arrive still
$$ as an attachement, not part of the email body ?
This is quickly turning into a FAQ.....
Abigail
--
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))
------------------------------
Date: Wed, 03 Mar 1999 10:22:57 +0100
From: Chris Oudeman <c.m.oudeman@st.hanze.nl>
Subject: Matching and replacing patterns..
Message-Id: <36DCFF71.FAFB6925@st.hanze.nl>
I think i'm doing this far to complex..
I want to convert this string:
<A HREF="/photo/snap.cgi?links=/programs/bv.html&rechts=/dir/b.htm">
into this string:
<A HREF="javaScript.MyFunction('/programs/bv.html','/dir/b.htm')">
(The "/programs/bv.html" and "/dir/b.htm" are of course dynamic)
And after a much to long day, i've got:
$_=~s/\/photo([^"]*")/$temp=$1/ge;
$temp=~s/=([^&]*&)=([^"]*")/javaScript.MyFunction('$1', '$2')">/g;
$_=$temp;
I know this doesn't make any sense:)
But could anybody help me, please?
Thanks in advance,
Chris Oudeman
c.m.oudeman@st.hanze.nl
------------------------------
Date: Tue, 02 Mar 1999 23:24:05 -0500
From: Chris Morrow <morrowc@his.com>
To: DCash <dcashd@bellsouth.net>
Subject: Re: Merge 2 Password Files
Message-Id: <36DCB965.3C8269C8@his.com>
does:
cat /web1/home/.mmpasswd /web1/home/.oopasswd >> /web1/home/.htpasswd
NOT work?
-chris
(you can sort/uniq the two files also:
cat /web1/home/.mmpasswd /web1/home/.oopasswd | sort | uniq >>
/web1/home/.htpasswd
in case there are duplicates...)
DCash wrote:
>
> Is there a Free perl script that will help me merge 2 password files?
>
> both files are on the same server
>
> path examples
>
> /web1/home/.mmpasswd # This is the first password file
> /web1/home/.oopasswd # This is the 2nd password file
>
> I want to merge both in one file
>
> /web1/home/.htpasswd # The final password file.
>
> If anyone knows where I can get a small script that can do this. Let me
> know.
>
> Thanks
> DCash
------------------------------
Date: 3 Mar 1999 03:33:56 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: method overriden!
Message-Id: <7biaj4$1qi$3@client2.news.psi.net>
Ekkis (ekkis@arix.com) wrote on MMX September MCMXCIII in
<URL:news:Go%C2.6603$8N5.71131@typhoon-sf.pbi.net>:
;; >> >$self->init(@_) calls the init method for the object $self; since $self
;; >> >is of class c2, this is the subroutine c2::init.
;; >>
;; >> but, doesn't $self resolve differently depending on the scope of usage?
;; >
;; >No. That would defeat one of the main purposes of OO, after all. That's
;; >what lets me define a derived class that changes the behaviour of
;; >base-class functions.
;;
;;
;; I have no problem with overriding functions. If I want to inherit a bunch
;; of functionality but want to change certain behaviour, yes, I get to call
;; the base class's original function only if I want to. This means that when
;; my derived class's implementation calls the function, it really refers to
;; the new function i.e. its own (the one at the derived class's level) and not
;; the original one (the one at the base class level). The derived function
;; obscures the base function which is the desired behaviour. But why should
;; function calls in the base class's code all of a sudden start calling
;; functions it doesn't know anything about??
Because if you call a function in an object, it doesn't matter from
where you call it.
If you call '$obj -> foo ()', you call the first foo () in the left
first inorder walk through the inheritance tree. Always. No exceptions.
Regardless whether the current package happens to be in the inheritance
tree of $obj. That's irrelevant. You always get the same foo ().
;; Suppose Person and Employee both define method sleep() except
;; Person::sleep() means "go to bed, close eyes, etc." while Employee::sleep()
;; means "check that coast is clear, hide in a corner, etc."
;;
;; If method nightynight() were only implemented at the Person level (since
;; Employee typically doesn't work 24hrs/day) and it called sleep(), why should
;; it call Employee:sleep() and check for the boss?? shouldn't it call
;; Person::sleep() instead?
I cannot answer that question. That depends on how you sleep (), which
objects are involved, and how the inheritance tree is. If if Employee
inherits Person, and $obj is of class Employee, '$obj -> sleep ()' will
*ALWAYS* call Employee::sleep. It doesn't magically call Person::sleep
if the packager of the caller happens to be Person. That would be silly,
hard to learn and prone to obscure errors. Not to mention, break every
OO princible that's out there. Perl OO is horrible and broken enough,
but at least it got this right.
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
------------------------------
Date: 03 Mar 1999 04:53:51 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: method overriden!
Message-Id: <920437091.988540@thrush.omix.com>
Ekkis <ekkis@arix.com> wrote:
>snip<
: I have no problem with overriding functions.
First off, please call them "methods". It makes the OO types
happier. Thanks. :-)
: If I want to inherit a bunch of functionality but want to change certain
: behaviour, yes, I get to call the base class's original function only if I
: want to. This means that when my derived class's implementation calls the
: function, it really refers to the new function i.e. its own (the one at
: the derived class's level) and not the original one (the one at the base
: class level). The derived function obscures the base function which is
: the desired behaviour. But why should function calls in the base class's
: code all of a sudden start calling functions it doesn't know anything
: about??
Because it doesn't.
You have a "Car". Somewhere in your "Car" code you have a method
called "drive()". Somewhere else in this Car code you call drive().
Someone builds a BMW, which is a Car. They have there own way to
drive(). At some point code in the Car part is run that calls
drive(), but instead of calling the original Car->drive() it calls
BMW->drive().
This is what is wanted, because you would never drive() a BMW like
an ordinary Car, even if you based it off one.
: Suppose Person and Employee both define method sleep() except
: Person::sleep() means "go to bed, close eyes, etc." while Employee::sleep()
: means "check that coast is clear, hide in a corner, etc."
Then that is how the Employee sleep()s, and Person must respect
that.
: If method nightynight() were only implemented at the Person level (since
: Employee typically doesn't work 24hrs/day) and it called sleep(), why
: should it call Employee:sleep() and check for the boss?? shouldn't it
: call Person::sleep() instead?
No.
If Employee is overriding sleep(), it is (or should be...) doing
this to implement it's own way of sleep()ing, not some other
random bit of functionality.
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Tue, 2 Mar 1999 23:18:00 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: method overriden!
Message-Id: <1do29gl.16kfs5y1y3vaitN@bay1-134.quincy.ziplink.net>
Ekkis <ekkis@arix.com> wrote:
> But why should
> function calls in the base class's code all of a sudden start calling
> functions it doesn't know anything about??
It knows about them because it's calling the functions from a derived
object.
If you don't want method lookup, don't use the method calling syntax.
$self->foo(@args); # method lookup
foo($self, @args); # no method lookup
The perlobj documentation has more on this, under Method Invocation.
--
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
perl -e'for(sort keys%main::){print if $$_ eq 1}
' -s -- -' Just' -' another ' -'Perl ' -'hacker
' http://www.ziplink.net/~rjk/ [rjk@linguist.dartmouth.edu]
------------------------------
Date: Tue, 2 Mar 1999 16:42:05 -0800
From: "Ekkis" <ekkis@arix.com>
Subject: Re: method overriden!
Message-Id: <Vy%C2.6607$8N5.70246@typhoon-sf.pbi.net>
>> after all, why should references in the base class actually be obscured
by
>> derived classes?
>
>Because you might want to have your base class call
>
>$self->write($string);
>
>And have the write function behave differently between a Pencil and Pen
>class. Otherwise, what's the point of overloading write()?
Yes, I understand that Pencil->write() should not be the same as
Pen->write(), but why should WritingInstrument->write() actually resolve to
either Pen->write() or Pencil->write() since WritingInstrument doesn't know
anything about Pens and Pencils?
>> >You probably want to write
>> >
>> > $self->c1::init(@_);
>> >
>> >to ensure that the init method for class c1 is called.
I could. for that matter I might better call $self->SUPER::init(), but my
point is: why should I be responsible for initialising HIS stuff? why can't
he (the base class) initialise his own stuff when I first create him via
new()?
>> do you mean to say that I have to hard-code references to myself if
there's
>> ever the possibility that some derived class some day will use a name the
>> same as mine?
>
>Only if you don't want to use the derived class' functionality. And why
>wouldn't you want to do that?
I don't! not from the base class. Fomr the base calss I want to use base
functionality.
>> The derived class shouldn't have to know to call the base class's
>> init() or any other particular internal functionality of my class
>> otherwise good God!
>
>They should if they intend on overriding its behaviour.
yes, on this we agree. caller needs to know interface - but not
implementation. Why should derived classes have to know that new() calls
init()? init's just a helper function for new() - it's not meant to be
called by derived classes. And every class should be able to define its own
init() function without clobbering other classes internal workings. no?
------------------------------
Date: Tue, 2 Mar 1999 19:16:34 -0800
From: "Ekkis" <ekkis@arix.com>
Subject: Re: method overriden!
Message-Id: <5Q1D2.6995$8N5.71867@typhoon-sf.pbi.net>
makes sense. thank you for the time and effort. I swear, the web's a great
invention but the usenet! wow.
Martien Verbruggen wrote in message ...
>In article <1Z_C2.6597$8N5.70518@typhoon-sf.pbi.net>,
> "Ekkis" <ekkis@arix.com> writes:
>
>> the call to the object $o's init() will resolve to c2::init(). But why
>> should calls in a base class resolve to code defined in derived classes?
>> that is callback behaviour, not virtual functions.
>
>You're not calling init in the class c1 (in the c1::new() method). You
>are calling $self->init(). $self has been blessed into class c2, so it
>will call c2::init().
>
>If you explicitly want to call c1::init(), you could do something
>like:
>
> init($self, @_);
>
>instead of
>
> $self->init(@_);
>
>in the c1::new() method. It's not nice, but it will call the init
>function in the class that the method is in, instead of method in the
>class that the _object_ $self has been blessed into.
>
>I wouldn't do it that way though (see my other post in another branch
>of this thread), because it breaks proper inheritance, and you cannot
>code your subclasses without knowing the internals of your superclass
>anymore. It is much better to call SUPER in the method that needs the
>SUPER's functionality.
>
>Again: Perl's OO model here is correct, and it behaves as it should.
>
>Martien
>--
>Martien Verbruggen |
>Webmaster www.tradingpost.com.au | "In a world without fences,
>Commercial Dynamics Pty. Ltd. | who needs Gates?"
>NSW, Australia |
------------------------------
Date: Wed, 03 Mar 1999 02:12:08 -0500
From: Jeremy Hill <hilljere@msu.edu>
Subject: module for 'get' command?
Message-Id: <36DCE0C8.2A10F423@msu.edu>
Hi, I remember having a module that gave me a 'get'
command, so I could say something like:
use ICantRemember;
@HtmlFile = get("http://wherever.com/index.html");
or something similar. I've been searching around, and
have found many similar things, but none this simple.
Does anyone know what this module is? Thanks for
any help!!!
------------------------------
Date: Wed, 3 Mar 1999 08:39:29 +0100
From: "Nima Mortazavi" <nima.m@lyckseleNOSPAM.net>
Subject: Need Help with Regular expressions
Message-Id: <7biov0$97g$1@cubacola.tninet.se>
Hi
I have a text file with following row :
=========
Hi $name How are you
My name is $info{'name'}
This file is /etc/$fil.txt
I am working on Usa/$city/street
=======
Now , In my perl program, I want read the text file and replace the
variables in text file
with the existing value of variable , I use the following code in my
program.
================
$name = 'Jack' ;
$fil = 'readme' ;
$info{'name'} = 'Nima' ;
$city = 'Lycksele' ;
open (Hfil,"<$mytextfile") ; @Harray = <Hfil> ; close (Hfil) ;
for ($Hm = 0; $Hm <= $#Harray; $Hm++) {
$Harray[$Hm] =~ s/\$(\w+)/${$1}/g; # My Regular expressions
print "$Harray[$Hm]" ;
}
exit ;
================
My Regular expressions works with variable $name ,$fil and $city , but not
with variable $info{'name'} .
How Should I write my Regular expressions to works with all the 4 variables
?
--
Regards,
Nima Mortazavi
--------------------
Please remove NOSPAM to reply
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5041
**************************************