[11767] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5367 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 13 00:27:30 1999

Date: Mon, 12 Apr 99 21:00:16 -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           Mon, 12 Apr 1999     Volume: 8 Number: 5367

Today's topics:
        [Q] install & Setup BBS on Unix <H8905665@hanwha.co.kr>
        Best way to do this regexp? <gregm@well.com>
    Re: Best way to do this regexp? <rereidy@uswest.net>
    Re: Can Perl implement a state machine? (Sam Holden)
    Re: Hash symbol '%' a stylized what? <mpersico@erols.com>
    Re: Hash symbol '%' a stylized what? (Damian Conway)
        Help: Running an independent perl script from another ajeet@my-dejanews.com
        Newbie to programming; (Mohamad Kebbeh)
    Re: No clues to Win32::NetResource problem? <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
    Re: pattern matching (Sam Holden)
        Printing a file <a_branson_1998@yahoo.com>
    Re: Privacy for ...A followup question <a_branson_1998@yahoo.com>
    Re: Privacy for ...A followup question <a_branson_1998@yahoo.com>
    Re: Privacy for ...A followup question <a_branson_1998@yahoo.com>
    Re: Problem with Shishir Gundavarams guestbook <ffchopin@worldnet.att.net>
    Re: Q about Server Side Includes, Perl , and  CPU utili <a_branson_1998@yahoo.com>
    Re: Reading from file into an array.... (Sam Holden)
    Re: Removing last space (Larry Rosler)
    Re: The First Parameter in Bless??? (Sam Holden)
    Re: Where I Can Learn About Pearl And CGI Scripting? <ffchopin@worldnet.att.net>
    Re: Y2k issues with perl DBI? <rereidy@uswest.net>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 13 Apr 1999 00:07:33 GMT
From: "Brian Dooly" <H8905665@hanwha.co.kr>
Subject: [Q] install & Setup BBS on Unix
Message-Id: <9VvQ2.1424$UC6.2556@news.bora.net>

Hi All,

I'm managing the Unix Server for Homepage.
Now I want to construct BBS on this server.
I've a problem. I don't know the methode.

Please teach me the way or recommend the referenced site.

Thank you.




------------------------------

Date: Mon, 12 Apr 1999 19:18:56 -0700
From: Greg McCann <gregm@well.com>
Subject: Best way to do this regexp?
Message-Id: <3712A990.A2BF3C13@well.com>

I am new to regexps and I am wondering if I have found the best way to extract
the pathname from $0.  This is what I came up with.  I'm matching "/" or "\"
because I don't know if this will be on a *nix or NT server (I'm working on NT
now).

Just in case I am entirely on the wrong track I should explain that my purpose
is to determine the absolute path of my script's home directory so that my
script can know where to locate files which are always in the same place
relative to the script's home directory, even if the script is moved to a
different system or run from a different directory.  If there is a better way to
do this please let me know.  I've tried using relative paths in the script, but
they always seem to be relative to the directory that the script is run from,
not the script's own home directory.


#!/usr/bin/perl -w
use strict;

my $path_name = $0;
print "My program is:       $path_name\n";

# return everything up to and including the last "/" or "\" 
$path_name =~ s/(.*[\/|\\]).*/$1/;
print "It is in directory:  $path_name\n";



Greg


-- 

======================
Gregory McCann
http://www.calypteanna.com

"Be kind, for everyone you meet is fighting a great battle."  Saint Philo of
Alexandria


------------------------------

Date: Mon, 12 Apr 1999 21:14:33 -0600
From: Ron Reidy <rereidy@uswest.net>
Subject: Re: Best way to do this regexp?
Message-Id: <3712B698.490F6C01@uswest.net>

This is a multi-part message in MIME format.
--------------B0CEDD4BADD772AC96D81D4F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

perldoc File::Basename

Greg McCann wrote:

> I am new to regexps and I am wondering if I have found the best way to extract
> the pathname from $0.  This is what I came up with.  I'm matching "/" or "\"
> because I don't know if this will be on a *nix or NT server (I'm working on NT
> now).
>
> Just in case I am entirely on the wrong track I should explain that my purpose
> is to determine the absolute path of my script's home directory so that my
> script can know where to locate files which are always in the same place
> relative to the script's home directory, even if the script is moved to a
> different system or run from a different directory.  If there is a better way to
> do this please let me know.  I've tried using relative paths in the script, but
> they always seem to be relative to the directory that the script is run from,
> not the script's own home directory.
>
> #!/usr/bin/perl -w
> use strict;
>
> my $path_name = $0;
> print "My program is:       $path_name\n";
>
> # return everything up to and including the last "/" or "\"
> $path_name =~ s/(.*[\/|\\]).*/$1/;
> print "It is in directory:  $path_name\n";
>
> Greg
>
> --
>
> ======================
> Gregory McCann
> http://www.calypteanna.com
>
> "Be kind, for everyone you meet is fighting a great battle."  Saint Philo of
> Alexandria

--------------B0CEDD4BADD772AC96D81D4F
Content-Type: text/x-vcard; charset=us-ascii;
 name="rereidy.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Ron Reidy
Content-Disposition: attachment;
 filename="rereidy.vcf"

begin:vcard 
n:Reidy;Ron
x-mozilla-html:FALSE
org:Reidy Consulting, L.L.C.
version:2.1
email;internet:rereidy@uswest.net
title:Owner
x-mozilla-cpt:;0
fn:Ron Reidy
end:vcard

--------------B0CEDD4BADD772AC96D81D4F--



------------------------------

Date: 13 Apr 1999 02:35:38 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Can Perl implement a state machine?
Message-Id: <slrn7h5bbq.9gm.sholden@pgrad.cs.usyd.edu.au>

Jeffrey Davey <Jeffrey_Davey-P93404@email.mot.com> wrote:
>Greetings!
>
>I was wondering if anyone knows how adept Perl is at implementing a
>state machine.  The type we'd like to use is one that is table-driven,
>in that functions called within a state are referenced from within an
>array.  Haven't seen yet that Perl can do this.

Creating an array of references to subroutines is very easy in perl.
Calling those a subroutine given jsut it's array index is very easy
as well.

@subs = ( \&sub1, \&sub2, \&sub3 ); #assuming sub[123] exists...

or

@subs = (
         sub {
                <some code>
              },
         sub {
               <some code>
             },
         sub {
               <some code>
             }
        );

Followed somewhere by :

$subs[0]->('arg1','arg2');

or

&{$subs[1]}('arg1','arg2');
 

>
>Pointers to relevant information would be welcome.

'perldoc perlref' would be useful.
'perldoc -f sub' might be useful too.


-- 
Sam

Perl was designed to be a mess (though in the nicest of possible ways). 
	--Larry Wall


------------------------------

Date: Mon, 12 Apr 1999 23:04:56 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: Hash symbol '%' a stylized what?
Message-Id: <3712B458.63DEFDCF@erols.com>

Jonathan Stowe wrote:
> 
> On 12 Apr 1999 07:40:16 -0700, gerg@shell1.ncal.verio.com (Greg
> Andrews) wrote:
> 
> >damian@cs.monash.edu.au (Damian Conway) writes:
> >>
> >>         4. Perl Institute known as Department of Perl Affairs.
> >>
> >
> >s/Department/Ministry/  perhaps?
> >
> 
> It depends whether this body will be headed by A Secretary of State
> for Perl Affairs or a Minister for Perl Affairs of course ...
> 
> /J\

Ok, two questions:

1) How do we go about getting Larry to be knighted? Or should we just go around calling him Sir Larry anyway?
2) If Sir Larry were Brittish, what animal would have been the Perl Mascot? Certainly not a camel, yes?

-- 
Matthew O. Persico
http://www.erols.com/mpersico
http://www.digistar.com/bzip2


------------------------------

Date: 13 Apr 1999 03:35:41 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Hash symbol '%' a stylized what?
Message-Id: <7eue2d$bb5$1@towncrier.cc.monash.edu.au>

"Matthew O. Persico" <mpersico@erols.com> writes:

>Ok, two questions:

>1) How do we go about getting Larry to be knighted? Or should we just
>   go around calling him Sir Larry anyway?

	No, "Sir Larry" is irrevocably the cognomen of the late Lord Olivier.

        Thinking about it, though, making a contribution to The Theatre *is*
        by far the easiest way to win a British knighthood. Larry would
        just need to develop an sonorous Oxbridge accent, a penchant
        for overproduced Shakespearean drama, and a certain gravitas in
        delivery. Oh, and a highly ambiguous sexuality seems to help too!

	Or he could use Sir Robert Geldof's approach - chronic scruffiness
	and raising scads of cash for charity.

        Anyway, didn't you guys fight a war several hundred years ago
        so you wouldn't have to worry about British knighthoods and the
        like? Maybe we should be working out how to win him the
        Congressional Medal of Honour?


>2) If Sir Larry were Brittish, what animal would have been the Perl
>   Mascot? Certainly not a camel, yes?

	The hedgehog! But then Perl would be slow, prickly, and prone to
	fatal accidents on the Information Superhighway :-(

Damian


------------------------------

Date: Tue, 13 Apr 1999 01:48:17 GMT
From: ajeet@my-dejanews.com
Subject: Help: Running an independent perl script from another
Message-Id: <7eu7ov$rhu$1@nnrp1.dejanews.com>

Hello all!

I am building a web-based database search and update utility using perl on MS
SQL server.

The problem is my server is very slow and hence it takes ages to process and
load results. Is there a way by which I can run an independent perl script in
the background and preprocess the information? So, I can just print out the
results?

I would greatly appreciate any help!

Cheers
Ajeet

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Mon, 12 Apr 1999 23:22:30 -0400
From: du532@freenet.carleton.ca (Mohamad Kebbeh)
Subject: Newbie to programming;
Message-Id: <7eudas$aa5@freenet-news.carleton.ca>

hi people, =)

    I am not a very well established programmer and i hope to be coming to
this
newsgroup more often to learn more about ways to program etc. could someone
point me to some sites that give very clear instructions on specific
learning oriented programming? - well that is not what this post is for!

I really want to know how to do this :
How to make a simple script that pass-protects a website...only thing is,  I
want to learn how it is all done not just simply given a script it is too
easy to get one off the
WWW- i need to know how to make a HTML form for that script as well-  any
help offered would be very much apreciated !


ps remember to explain a lot I am new to this after all -





------------------------------

Date: Mon, 12 Apr 1999 20:35:48 -0700
From: "Dave Roth" <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
Subject: Re: No clues to Win32::NetResource problem?
Message-Id: <aWyQ2.9190$Jc7.516950@news2.giganews.com>

Chuck wrote in message <370FE25A.25B9E767@netscape.net>...
>
>
>Dave Roth wrote:
>
>> Ahhh. For some reason Win32::NetResource::NetShareGetInfo() requires
>> that the second parameter be a scalar, not a hash reference. If the
>> function is successful then the scalar will be set as a hash reference.
>> Try this:
>>  Win32::NetResource::NetShareGetInfo( $myshare, $share_info, $server );
>>  print "The Share path is: $share_info->{remark}.
>
>It will also give a runtime exception if $myshare points to a share point
that
>doesn't exist. I'm looking for a way to test the existence of a share
before I
>try to go there and pull up its information. I was hoping a 0 return upon
>failure of this function would work, but it chokes completely unless the
share
>already exists.
>Is there another way to do this? Win32::NetResource::NetShareCheck would be
>perfect for this if it worked, and Dave says not to use it in his book.
;-)

Yeah, NetShareCheck() seems to be as broken as can be -- mind you it is not
the extensions authors fault. The Win32 API function seems broken.
You should be able to do something like:
    -d '\\\\server\share' || die "no such UNC";
However there are two issues here:
  1) If you don't have permissions on the share it may fail
  2) Perl 5.005 has a bug which -d will always fail if you specify
     a UNC root. I submitted a patch to this way back for ActiveState
     build 310 (or thereabouts) and it was fixed in the next release.
     However Perl 5.005 seems to have lost the patch.

dave

--
=================================================================
Dave Roth                                ...glittering prizes and
Roth Consulting                      endless compromises, shatter
http://www.roth.net                     the illusion of integrity
Win32, Perl, C++, ODBC, Training
rothd at roth dot net

Our latest Perl book is now available:
"Win32 Perl Programming: The Standard Extensions"
http://www.roth.net/books/extensions/





------------------------------

Date: 13 Apr 1999 02:43:48 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: pattern matching
Message-Id: <slrn7h5br4.9gm.sholden@pgrad.cs.usyd.edu.au>

Fu Chin Liu <fuchin@mail.nwos.lucent.com> wrote:
>Try /^\d+$/ .

If you consider "123\n" to be 'composed of digits only'.
If the original poster meant how to check if the variable is a number then
perlfaq4 : How do I determine whether a scalar is a number/whole/integer/float?
would have been a good place to look (and agrees with the above solution).

I prefer '! /\D/' myself though...(and the faq mentions it too).

>
>bing-du@tamu.edu wrote:
>>
>> How to judge if a variable is composed of digits only?

-- 
Sam

If your language is flexible and forgiving enough, you can prototype
your belief system without too many core dumps.
	--Larry Wall


------------------------------

Date: 13 Apr 1999 03:35:17 GMT
From: "Andrew Branson" <a_branson_1998@yahoo.com>
Subject: Printing a file
Message-Id: <7eue1l$kia$0@208.231.50.193>

I am sorry if this is a stupid question, but I am fairly new to Perl:  I
there a way to read and print() an entire file as opposed to line by line?
Thanks.

Andy





------------------------------

Date: 13 Apr 1999 02:55:58 GMT
From: "Andrew Branson" <a_branson_1998@yahoo.com>
Subject: Re: Privacy for ...A followup question
Message-Id: <7eubnu$fuv$0@208.231.50.193>

I just wanted to confirm that Basic Auth over SSL was encryped. And no, I
not worried about people deciphering packets (I not dealing with super
secrets), I would just prefer if curious george the sys admin kept his nose
out of my business :-)
Thanks.

Andy



LAN Boy wrote in message <37116f85.23326755@news.ne.mediaone.net>...
>Help me out here:  Exactly what is the concern/problem with using
>"basic authentication" scheme if the connection is being forced to use
>SSL?  Are you concered your present employer might sniff your SSL'd
>login, crack the username/pwd, and then access your website?!  Maybe
>I'm missing something with respect to Basic Auth over SSL?  Is it NOT
>encrypted via SSL, too?
>
>I should think that forcing the connection attempt to use SSL would be
>sufficient to prevent all but the most determined hacker (and well
>funded one, at that) from sniffing your logon and deciphering the
>packets to yield the logon info.  No?
>
>-LB
>
>On 12 Apr 1999 03:00:57 GMT, "Andrew Branson"
><a_branson_1998@yahoo.com> wrote:
>
>




------------------------------

Date: 13 Apr 1999 03:04:06 GMT
From: "Andrew Branson" <a_branson_1998@yahoo.com>
Subject: Re: Privacy for ...A followup question
Message-Id: <7euc76$gu0$0@208.231.50.193>

>> If I access my personal web site (which is running SSL) can the admin see
>> the content of my web site. Also, if I use basic HTTP authentication
>> (.htaccess, etc.) will the admin be able to intercept my password and log
on
>> to my SSL site?
>>
>
>Yes and Yes; if they are any good at being admins.
>That's why they are called admins to start with.
>
>-Sneex-  :]



Really?! Are you sure? OK I wasn't sure that basic authentication was going
to be encrypted, but I thought that all the SSL communication is secure. How
can anyone (including the sys admin) see the content of the communication (I
don't mean cracking the encryption) over an SSL channel?

Is there any way around this? Thanks.

Andy








------------------------------

Date: 13 Apr 1999 03:05:10 GMT
From: "Andrew Branson" <a_branson_1998@yahoo.com>
Subject: Re: Privacy for ...A followup question
Message-Id: <7euc96$h24$0@208.231.50.193>

Thanks. This is what I was hoping to hear.


Jordan Krushen wrote in message ...
>HTTP authentication, being HTTP, and thus on top of the SSL layer, is
>encrypted too.
>
>J.
>





------------------------------

Date: Mon, 12 Apr 1999 23:03:15 -0400
From: "Jason Simms" <ffchopin@worldnet.att.net>
Subject: Re: Problem with Shishir Gundavarams guestbook
Message-Id: <7euc8d$ann$1@bgtnsc02.worldnet.att.net>

> What am I doing wrong ? Do I have to write a "guestbook.html" myself
> or does the guestbook.pl create one itself ?

I entirely agree with Jonathan - you really ought to be using CGI.pm.  Read
the CGI chapter (hell, the whole book) in Learning Perl, and then check out
the Official Guide to Programming with CGI.pm, by Lincoln Stein (he wrote
the module, also).  Your life will be much better because of it... :-)
Truly, though, it is easier and better than what you're trying to do.  Also,
any further questions on CGI will best be taken to
comp.infosystems.www.authoring.cgi, where they are more on-topic and where
you will find better and more responsive answers to your problems.

Jason Simms




------------------------------

Date: 13 Apr 1999 03:18:12 GMT
From: "Andrew Branson" <a_branson_1998@yahoo.com>
Subject: Re: Q about Server Side Includes, Perl , and  CPU utilization
Message-Id: <7eud1k$iif$0@208.231.50.193>

Lee wrote in message ...
<snip>
>As I'm sure you will be told a dozen times or more, this Q should be in
>comp.infosystems.www.servers...
>

Oops, sorry - I'll repost it there.







------------------------------

Date: 13 Apr 1999 02:07:43 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Reading from file into an array....
Message-Id: <slrn7h59nf.9gm.sholden@pgrad.cs.usyd.edu.au>

On Mon, 12 Apr 1999 15:39:58 +0100, Andrew Weller <p8e77@keele.ac.uk> wrote:
>Dear All,
>
>I need to write some code in Perl to do the following:
>
>I'm trying to read in a data file which looks like the following:
>
>head       -26.27939        43.58512        14.08601        43.43750
>head       -26.14723        43.68331        14.11775        40.93750
>head       -28.55041        48.04858        15.52853        50.81250
>head       -27.17389        46.06922        14.88883
>63.93750......etc.....
>
>This data can vary from 1 entry to an infinite amount. I would like to read
>the file in and loop through the set until it reaches the end, reading each
>entry (as: text, xvalues, yvalues, zvalues, intensity).

It's going to be very difficult to reach 'the end' of an 'infinite' amount.
Maybe you meant finite but unbounded amount or something similar.
Maybe I'm just being picky...

>My current code looks like this:

>get_filename ();
>    open (READFILE, $filename) || die "Can't read $filename: $!";
>    while (<READFILE>) {
>        chomp;
>        my ($text, $xvalues, $yvalues, $zvalues, $intensity) = split;
>        print "$text \t $xvalues \t $yvalues \t $zvalues \t $intensity\n";
>}
>-------------------
>
>Although this works fine - what I'm after is, instead of the values being
>printed to screen with the following line:
>
>print "$text \t $xvalues \t $yvalues \t $zvalues \t $intensity\n";
>
>I want the variables to be saved as an array, so that they can be
>manipulated later and saved to a new file.

Use something like :

push @lines, [ split ];

Instead of the split and print lines in your code.

Rather than just using code posted by someone that you have never even
heard of before and have no reason to trust... you should have a look
in the documentation to see how to do it yourself.

'perldoc perllol' would be most beneficial. I haven't shown you how to 
access the array afterwards anyway, so you will need to do some reading.

'perldoc perlref' might prove interesting too...

-- 
Sam

I don't want Perl to be beautiful--I want you to write beautiful
programs in Perl.
	--Larry Wall


------------------------------

Date: Mon, 12 Apr 1999 19:44:45 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Removing last space
Message-Id: <MPG.117c4f64605f402198989f@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <7eu2bb$4po$1@news.uky.edu> on 13 Apr 1999 00:15:39 GMT, 
Aaron B. Dossett <aarond@alpha.ewl.uky.edu >says...
> Larry Rosler (lr@hpl.hp.com) wrote:
> : 
> : I would answer the literal question that was actually asked this way:
> : 
> :     s/ (?=[^ ]*$)//
> : 
> : This indeed removes the last space from a variable -- only one space, 
> : the last one in the string (but not necessarily a 'trailing' space).
> :  
> 
> I'm glad I wasn't the only person who interpreted the question that way.
> What immeadiately popped into my mind was:
> 
>       s/^(.*) (.*)$/$1$2/;
> 
> But I'm sure yours is much faster.

You're right.  But benchmarking is better than conjecture.  (I 
simplified your regex a bit, to save unnecessary work.)

#!/usr/local/bin/perl -w
use Benchmark;

my $s0 = ' ' . 'x' x 100;
my $s1 = 'x' x 100 . ' ';
my $s2 = 'x' x 100;

timethese(1 << (shift || 0), {
  S0 => sub { (my $x = $s0) =~ s/(.*) /$1/ },
  S1 => sub { (my $x = $s1) =~ s/(.*) /$1/ },
  S2 => sub { (my $x = $s2) =~ s/(.*) /$1/ },
  T0 => sub { (my $x = $s0) =~ s/ (?=[^ ]*$)// },
  T1 => sub { (my $x = $s1) =~ s/ (?=[^ ]*$)// },
  T2 => sub { (my $x = $s2) =~ s/ (?=[^ ]*$)// },
});
__END__

Benchmark: timing 65536 iterations of S0, S1, S2, T0, T1, T2...
        S0:  8 wallclock secs ( 7.47 usr +  0.00 sys =  7.47 CPU)
        S1:  4 wallclock secs ( 4.12 usr +  0.00 sys =  4.12 CPU)
        S2:  1 wallclock secs ( 0.77 usr +  0.00 sys =  0.77 CPU)
        T0:  1 wallclock secs ( 2.31 usr +  0.00 sys =  2.31 CPU)
        T1:  2 wallclock secs ( 1.32 usr +  0.00 sys =  1.32 CPU)
        T2:  1 wallclock secs ( 0.71 usr +  0.00 sys =  0.71 CPU)

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: 13 Apr 1999 02:27:18 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: The First Parameter in Bless???
Message-Id: <slrn7h5as5.9gm.sholden@pgrad.cs.usyd.edu.au>

Sys Adm 89806 <ruben@llinderman.dental.nyu.edu> wrote:
>In article <7et70j$7in$1@news.nyu.edu,
>	ruben@llinderman.dental.nyu.edu (Sys Adm 89806 Manager of programing development and Intranet Resources) writes:
> Does anyone know in more detail what Sriram Srinivasan  means in "Advanced
> Perl Programing" when he says on page 106 in Chapter 7,
> 
> When Perl sees $empl1-promote(), it determines the class to which
> $empl1 belongs.  In this case, it is the Regular-Employee (which I think is a
> typo in the book since the type is RegularEmployee without the dash).  Perl then calls this function as follows:  RegularEmployee::promote($empl1). In other
>  words, the object on the left side of the arrow is simply given as a parameter
>  of the appropriate subroutine.
> 
> This last line is loosing me because a parameter is in the list given to the
> subroutine.  In C++ - indeed we do use this syntax in the constructor in that
> it is self referencing.

I'm not sure what you mean...

When a method is called on an object ($empl1->promote() above) what perl
actually does is see what class $empl1 is, by seeing what the thing it 
points to was 'blessed' to be. That gives perl the package to look
in to find a sub called promote (in this case that package is
RegularEmployee. Since there are things like inheritance
promote may be called in some base classes package, but for 
simplicity assume promote is defined in the package RegularEmployee.

In other words there exists a sub RegularEmployee::promote.

So perl calls that sub passing $empl1 as the first argument, and the
actual arguments as the code as the rest (in this case there are none).

So $empl1->promote() could also be written as
RegularEmployee::promote($empl1). Except that that would not allow you
to use inheritance which is rather important for anything claiming to
be OO.


> 
> Here, I don't see any such thing.  The suboutine new doesn't seem to
> have a parameter for the package name.  Only in the bless clause is
> this given as
> 
> bless $r_employee, 'RegularEmployee';

That sort of syntax shouldn't really be used. That blesses whatever
$r_employee references to be in the class RegularEmployee. However, since
we want inheritance, we need to be able to make a class that inherits from
RegularEmployee. To save us the work of having to rewrite the new sub
for each class perl lets us use the base class' one.

It does this by passing the name of the class to the sub. So code like :

new RegularEmployee() or RegularEmployee->new() is translated into something
like : RegularEmployee::new('RegularEmployee') except again inheritance means
that if there is no RegularEmployee::new then the base classes will be checked.
So if RegularEmployee inherited from Person and there was no new sub in the
RegularEmployee package (and there was one in Person) then perl would use :
Person::new('RegularEmployee').

> 
> With static class methods, it seems that he's changing his mind on this
> and is adding a scalar $pkg to the parameter list.  Why would it be needed
> for a static Method and not an instance?

Class methods (ie constructors) are always passed the package name as
the first argument.

RegularEmployee->new('fred') gets treated as (again ignoring inheritance)
RegularEmployee::new('RegularEmployee','fred').
RegularEmployee->anysub(@args) gets treated as (again ignoring inheritance)
RegularEmployee::anysub('RegularEmployee',@args).

Methods calls are always passed the object as the first argument.

If $bill is a RegularEmployee (ie $bill = RegularEmployee->new() was used)
then (again ignoring inheritance) :

$bill->set_pay($pay) gets treated as RegularEmployee::set_pay($bill,$pay).

> 
> I'm very confused about what is happening here.

Since my explanation is ununderstandable even to me you should read the 
documentation that comes with perl...

perldoc perltoot

-- 
Sam

Every human culture has good and bad points. Every computer program has
Eveone more bug. Even Perl.
	--Larry Wall


------------------------------

Date: Mon, 12 Apr 1999 22:53:11 -0400
From: "Jason Simms" <ffchopin@worldnet.att.net>
Subject: Re: Where I Can Learn About Pearl And CGI Scripting?
Message-Id: <7eublj$7mb$1@bgtnsc02.worldnet.att.net>


<ellerp@my-dejanews.com> wrote in message
news:7etuti$k4u$1@nnrp1.dejanews.com...
> In article <19990412123424.21220.00003207@ngol01.aol.com>,
>   barneyxter@aol.com (BarneyXter) wrote:
> > The Title Says It All.  I Want To Learn How To Make A Chat Room And Have
Pages
> > That I Can Input Text From...
> >
> My recommendation for learning Perl is:
> Perl 5 Interactive Course by Jon Orwant, published by Waite Group Press.
>
> For CGI programming it is:
> CGI Programming (what else) on the World Wide Web, by Shishir Gundavaram,
> published by O'Reilly & Assoc.

While this is an excellent book, I might suggest a different combination (if
you will indeed be using Perl for CGI).  First, read Learning Perl, which
has a good introductory chapter on CGI.  Then, read the Official Guide to
Programming with CGI.pm, by Lincoln Stein (he wrote the CGI.pm module, as
well).  I have yet to find a better starting place for CGI than these two
resources, and you'll learn a good deal about Perl in the meantime.

Jason Simms




------------------------------

Date: Mon, 12 Apr 1999 20:30:00 -0600
From: Ron Reidy <rereidy@uswest.net>
Subject: Re: Y2k issues with perl DBI?
Message-Id: <3712AC28.427A990A@uswest.net>

This is a multi-part message in MIME format.
--------------55F22940FF73D20045F56511
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Yes,

Don't do it!

rr

Keith Kwiatek wrote:

> Any y2k issues with Perl and DBI I need to be aware of?

--------------55F22940FF73D20045F56511
Content-Type: text/x-vcard; charset=us-ascii;
 name="rereidy.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Ron Reidy
Content-Disposition: attachment;
 filename="rereidy.vcf"

begin:vcard 
n:Reidy;Ron
x-mozilla-html:FALSE
org:Reidy Consulting, L.L.C.
version:2.1
email;internet:rereidy@uswest.net
title:Owner
x-mozilla-cpt:;0
fn:Ron Reidy
end:vcard

--------------55F22940FF73D20045F56511--



------------------------------

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 5367
**************************************

home help back first fref pref prev next nref lref last post