[12230] in Perl-Users-Digest
Perl-Users Digest, Issue: 5830 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 29 21:07:24 1999
Date: Sat, 29 May 99 18:00:21 -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 Sat, 29 May 1999 Volume: 8 Number: 5830
Today's topics:
Re: $^O and all types? <sugalskd@netserve.ous.edu>
Re: ActiveState/ActivePerl <gellyfish@gellyfish.com>
Re: cont'd (Ronald J Kimball)
Re: FAQ 3.24: How can I get C<#!perl> to work on [MS-DO (Jeff Zeitlin)
Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe <tchrist@mox.perl.com>
Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe <gellyfish@gellyfish.com>
Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe (Alastair)
Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe (Paul Kimoto)
Re: file upload <gellyfish@gellyfish.com>
How do I sort unique items from a sorted array? <aef@pangea.ca>
How do I tell which user is logged on with Perl? (ace)
Re: how to upload file from the form? <globus@infonet.ee>
Re: Im not asking for much (Abigail)
Re: In favor of extending "my" to apply to subroutines (Abigail)
Re: localtime problems... (Abigail)
Re: London.pm Meeting <gellyfish@gellyfish.com>
Re: MacPerl - ping other hosts (Henry Penninkilampi)
Re: Making executables from .pl files? (Abigail)
Re: Newsfeed and Local Weather (Abigail)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 29 May 1999 22:11:31 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: $^O and all types?
Message-Id: <7ipomj$12e$1@news.NERO.NET>
$Richy Rich$ <rich_guy@hotmail.com> wrote:
: i'm trying to make my scripts more portable, and also make it easier for
: people that use them and set them up. this of course, would involve
: knowing what OS they are using. i need to check it to know if (depending
: on the OS) i can use flock, do forking, etc. and what will and will not
: work with windows that will work with unix, and what will and will not
: work with certain versions of certain OS's. is the $^O the only thing i
: can check this with? i've found that more then a few hosts don't allow
: some type of commands to be executed, i.e., "ps", which makes it
: difficult to kill a process id that may be sitting around too long. i'm
: wondering if there's a site that lists the different OS's and how to
: find out if they support flock, fork, etc. and have the script react
: depending on what they do.
The Config module is your friend here. perldoc Config and be enlightened.
Dan
------------------------------
Date: 29 May 1999 20:10:56 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: ActiveState/ActivePerl
Message-Id: <7iphkg$317$1@gellyfish.btinternet.com>
On Sat, 29 May 1999 18:21:41 +0100 Edmund Paddington wrote:
> I wonder if anyone can help me?
>
> I've just started learning perl and CGI. I am running windows 95 on an AMD
> K6. I've downloaded the ActiveState ActivePerl installer and at the same
> time DCOM95 and I have installed both (DCOM first). As I understand it,
> output from any perl script is supposed to be routed to the browser,
> allowing you to test cgi that is embedded in HTML documents from within your
> browser, without having to bother your ISP (they want to vet each script
> before allowing it to run).
>
I'm sorry I think your understanding is false. You will need to install
some HTTP server on your PC if you want to that. However that is out of
the scope of this group, you will find instructions on how to make
ActivePerl work with various HTTP servers in the documenatation that
was put in your start menu as part of the install process. If you want
advice on the choice of server you will probably want to ask in the group:
comp.infosystems.www.servers.ms-windows
Remember that the majority of uses that Perl is put to have nothing to do
with CGI and most people in this group are fairly clear about that.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sat, 29 May 1999 20:07:00 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: cont'd
Message-Id: <1dsl0ak.53c65y1kr2hkwN@p112.tc3.state.ma.tiac.com>
Uri Guttman <uri@sysarch.com> wrote:
> i politely disagree. he could have been referring to some wacko curses
> type thing where he wanted to output some lines after/below others. and
> he never said anything about why it had to be single quotes and he never
> showed any code (broken or otherwise). so my comments on the muddiness
> of the requests is still valid. you interpret them to be newlines in
> strings which is a legitimate response but who knows wht he really wants
> unless he is clearer about his goals.
He's talking about pressing return and printing "\n". Where do you get
curses from that??
I'm not sure what you mean by "it had to be single quotes" - it didn't
have to be single quotes, he just wanted to know how to do it in single
quotes and in double quotes.
And he did show code:
print "\n";
print "\n";
print "\n";
print "\n";
print "\n\n\n\n";
which, I think, shows pretty clearly what he is trying to do: start a
new line in the output! Obviously, he knows a way to do it; he just
wanted to make sure this was the right way.
BTW, tia is 'Thanks In Advance' and jrk is the poster's initials.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 29 May 1999 17:37:44 -0500
From: jzeitlin@cyburban.com (Jeff Zeitlin)
Subject: Re: FAQ 3.24: How can I get C<#!perl> to work on [MS-DOS,NT,...]?
Message-Id: <375c3e58.70690024@news.cyburban.com>
Tom Christiansen <perlfaq-suggestions@perl.com> wrote:
> How can I get `#!perl' to work on [MS-DOS,NT,...]?
If you are using the replacement command processors from
JPSoftware (4DOS, 4OS2, 4NT) or the Windowed Command Line
products (Take Command/16, Take Command/32, Take Command for
OS/2), you can create an 'executable extension' pointing to the
actual location of the perl interpreter:
SET .pl=C:\path\to\perl.exe
This eliminates the need to worry about the #! line. It does not
affect the registry, and thus will not allow click execution in
graphical environments (Windows[any] or OS/2 PM). It does,
however, allow the execution of a perl program myprog.pl by just
typing 'myprog' (without the quotes) from the prompt.
In 4OS2, 4NT, and Take Command, the EXTPROC method described for
OS/2 will work, even on non-OS/2 operating systems.
--
Jeff Zeitlin
jzeitlin@cyburban.com
------------------------------
Date: 29 May 1999 18:01:20 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <37507fd0@cs.colorado.edu>
In comp.lang.perl.misc, finsol@ts.co.nz writes:
:In the same section of my article I also included CICS, MVS and
:Javascript - all of which could be disputed as being a programming
:language.
MVS is clearly not a programming language. Javascript, equally clearly,
*is* a programming language, albeit an ill-regarded one. That you can
equivocate -- or prevaricate -- here suggests what a tattered patchwork
your understanding must really be.
:For the purposes of the article, in which I tried to avoid as
:much jargon as possible,
To the contrary, you avoided as much *technical accuracy* as possible.
Now with each posting refusing to admit the wrong, you just dig the
hole that much deeper.
--tom
--
I am a little more weird today than normal. --Andrew Hume
------------------------------
Date: 30 May 1999 00:16:54 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <7iq01m$384$1@gellyfish.btinternet.com>
In comp.lang.perl.misc finsol@ts.co.nz wrote:
> In article <slrn7kqsao.vm.sitaram@diac.com>,
> sitaram@diac.com (Sitaram Chamarty) wrote:
>> On Thu, 27 May 1999 14:36:01 GMT, finsol@ts.co.nz <finsol@ts.co.nz>
> wrote:
>>
>> >Tom, thought you may be interested to know that I'm not the only
>> >mis-guided soul using the term "programming language" to describe CGI
>> >for expedience.
>>
>> You may have used it for "expedience" to start with - although I
>> doubt that. But you cannot hide behind that word now, after
>> arguing vociferously with everyone here that it *is* indeed a
>> language. A full paragraph is not "expedient" in any way.
>>
>> Give it up, sister!
>>
> In the same section of my article I also included CICS,
Which is a transaction processing subsystem for IBM computer
> MVS
Which is an operating system for IBM computers.
> and
> Javascript
Which may or may not be a *programming* language depending on how you
look at it.
> - all of which could be disputed as being a programming
> language.
Rubbish. The first is a system for transaction processing - a middleware
product if you must. People program to its interface in a variety of
different languages - IBM I believe support COBOL,Java,ReXX,Smalltalk and
others. It has as far as I can tell no native programming facilities.
The second is an operating system what more can I say - is Unix a
programming language, is windows NT ? get a grip.
> For the purposes of the article, in which I tried to avoid as
> much jargon as possible,
Unfortunately what you describe as 'jargon' are precise technical terms
that are essential when discussing this kind of essentially technical
subject. You cant afford to be tabloid or populist when dealing with
this stuff because you are addressing people who can distinguish your
taurocoproloquy from the real thing - this is an educated audience not
a bunch of PHBs who might be impressed by language that they can
understand.
> it was convenient to describe them as
> programming languages, as programmers use them for
> instructing computers i.e. programming.
Some people might feel that they use their mouse to instruct their
computer - is that programming ?
> My point was to draw attention
> to these languages as having a problem - which they do.
I hope you now understand that neither MVS, nor CICS, nor CGI is a
programming language and will desist from referring to them as such if
you want people to take you seriously.
> You are only
> arguing semantics because you are unable to sucessfully argue against my
> main point which is that the Perl programming language is Y2K booby
> trapped.
>
This is not semantics - it is the clarification of a misuse of technical
terms. If you cannot clearly distinguish between an operating system,
a middleware product and a programming language it draws into question
your ability to determine whether any of these things have a problem
of any kind - and quite frankly I wouldnt trust you to determine that
it was unnecessarily easy to swap the keycaps over on my keyboard on
this standing. You can, nay you *should* do better, you do yourself, and
this thing that you obviously feel quite strongly about, a great disservice
by trying to talk to technical people as if they were a bunch of dumb
punters.
> You would do the Perl community more credit by working on Y2K awareness,
> not clouding the issue unecessarily.
>
As has been said ad nauseam in this thread there is very little more that
can be said than :
Also, $year is the
number of years since 1900, that is, $year is 123
in year 2023, and not simply the last two digits
of the year.
I dont think anyone is trying to cloud the issue, I just think that they
all regard that statement to be fairly definitive and explicit and that
anyone who has either failed to read, failed to understand or ignored it
will find their own particular Pit of Malbowges sooner or later. There
really isnt much more that can be done is there ?
Take it to alt.perl
/j\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 30 May 1999 00:25:53 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <slrn7l14vp.5f.alastair@calliope.demon.co.uk>
finsol@ts.co.nz <finsol@ts.co.nz> wrote:
>In the same section of my article I also included CICS, MVS and
>Javascript - all of which could be disputed as being a programming
>language. For the purposes of the article, in which I tried to avoid as
>much jargon as possible, it was convenient to describe them as
>programming languages, as programmers use them for
>instructing computers i.e. programming. My point was to draw attention
>to these languages as having a problem - which they do. You are only
>arguing semantics because you are unable to sucessfully argue against my
>main point which is that the Perl programming language is Y2K booby
>trapped.
CICS and MVS are not programming languages. Period. How many other errors can I
expect to find in your arguments? To me, this is fairly basic stuff. Why should
I trust your judgement on Y2K?
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: 29 May 1999 20:51:44 -0500
From: kimoto@lightlink.com (Paul Kimoto)
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <slrn7l12sv.r8h.kimoto@autolycus.antigonus.net>
In article <7iljav$554$1@nnrp1.deja.com>, finsol@ts.co.nz wrote:
> In article <slrn7krnjc.2uj.fl_aggie@thepentagon.com>,
> fl_aggie@thepentagon.com wrote:
>> On Thu, 27 May 1999 23:12:43 GMT, Bob Shair <bshair@itds.com>, in
>> <7ikjh9$f3r$1@nnrp1.deja.com> wrote:
>>+ If you're suggesting that Perl should unilaterally change the behaviour
>>+ of localtime() to (1) break all the code which was written properly
>> Causing an even larger Y2K-ish problem...
> When did I ever suggest or imply that? That would be as stupid as the
> original decision to return the value 100 for the year in the year 2000.
Interesting. All right, given an established precedent that the year
would take values starting with the number 70, what should the people
who wrote the C library specification have decreed should be returned
for the year 2000?
--
Paul Kimoto <kimoto@lightlink.com>
------------------------------
Date: 29 May 1999 20:28:53 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: file upload
Message-Id: <7ipim5$31a$1@gellyfish.btinternet.com>
On Sat, 29 May 1999 12:06:06 -0400 Jeff Thies wrote:
>
> I realize this is a stupid newbie question and that this is more a CGI
> question but I can't post to comp.infosytems.www.authoring.cgi (???) so
> you are stuck with me!!!
>
I'm sorry thats not how it works. The hierarchical arrangement of USENET
is there for a reason and ignoring it will do you no good. 'I got a
problem re-upholstering this antique chesterfield but I couldnt post
to alt.furniture.restoration so I thought I'd ask here if it was alright
to use synthetic stuffing as opposed to horse-hair ...'
Can you explain clearly what part of the documentation of CGI.pm you
dont understand - infact first I would recommend you to go to
<http://www.webreview.com> and look at the article by Brent Michalski
on this very subject.
Then if you still have a Perl problem as opposed to a CGI one please
feel free to post the smallest snippet of code that manifests the
problem you are incurring and I am sure that people will be delighted
to help...
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sat, 29 May 1999 18:25:43 -0500
From: "AEF" <aef@pangea.ca>
Subject: How do I sort unique items from a sorted array?
Message-Id: <7ipt0l$602$1@pumpkin.pangea.ca>
Still having problems with sorting. Please help.
How do I...
With an array of sorted wages of all the data of various job categories,
sort the job categories that exist in the array into order of the higest to
lowest paid job category, and print the job category only once. (That will
be used as the table header for the data of subcategories).
Job Category Highest Paid
subcategory wage data1
data2
Job Category Next
this sub data1
data2
Job Category Lowest
data1
?
Thanks.
------------------------------
Date: Sat, 29 May 1999 22:50:28 GMT
From: kawaii_1@hotmail.com (ace)
Subject: How do I tell which user is logged on with Perl?
Message-Id: <37506e24.3412249@news-server>
I'm trying to write a script that will log to a text file the user
that accessed my htaccess protected area by logging in through
the popup window created by htaccess (or whatever does it)
Upon entering my members' area url I would like the script to log
which user is there.
How can I determing who the current user is? The url in the browser
after logging in DOES NOT LOOK LIKE THIS:
myid:mypassword@www.domain.com
It only looks like this:
www.domain.com
Anyone have any ideas how to do this?
thanks in advance.
------------------------------
Date: Sun, 30 May 1999 03:43:38 +0300
From: Gleb Ekker <globus@infonet.ee>
Subject: Re: how to upload file from the form?
Message-Id: <375089BA.2E3EBF43@infonet.ee>
Is it really such hard problem that it can not be done without using any
module? My provider do not allow to use perl modules and this provider is
the only one who allows to use perl scripts in our country - Estonia.
Maybe it is some way to upload files to the server without CGI.pm? In fact,
I want to upload only text files.
Thanks for any idea. Gleb.
Anthony Baratta wrote:
> Gleb Ekker wrote:
> >
> > Hi everybody,
> >
> > please, help is needed. I want to upload to the server a file from the
> > form.
> > I use <input name='data' TYPE='file'> in the form and Perl script get
> > from it only path to a file and file name.
> > How can script get the file from a local machine for the futher
> > processing?
>
> get cgi-lib.pl
>
> http://cgi-lib.stanford.edu/cgi-lib/
>
> Read the pages on file uploads.
>
> --
> Anthony Baratta
> President
> KeyBoard Jockeys
> South Park Speaks Version 3 is here!!!
> http://www.baratta.com/southpark
> Powered by Tsunami
------------------------------
Date: 29 May 1999 19:08:24 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Im not asking for much
Message-Id: <slrn7l10p5.7ub.abigail@alexandra.delanet.com>
I R A Aggie (fl_aggie@thepentagon.com) wrote on MMXCVI September MCMXCIII
in <URL:news:slrn7ku0c1.f6.fl_aggie@thepentagon.com>:
%%
%% Depends on how one parses "starting perl programmer". Are you:
%%
%% a) a programmer wanting to learn perl
%% b) a person wanting to learn to program, in this case, in perl
%%
%% $answer=<STDIN>;
%% if ( (lc $answer)=~/a/) {
%% print "Learning Perl by Randal Schwartz\n";
That would be "Randal Schwartz and Tom Christiansen".
However, I would recommend "Perl: The Programmers Companion" instead.
More useful for people who can already program, IMO.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 29 May 1999 18:01:20 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: In favor of extending "my" to apply to subroutines as well as variables
Message-Id: <slrn7l0sr7.7ub.abigail@alexandra.delanet.com>
Tom Christiansen (tchrist@mox.perl.com) wrote on MMXCIII September
MCMXCIII in <URL:news:374ab1ef@cs.colorado.edu>:
==
== Tell me, have you read what the perltoot manpage says about "Closures as
== Objects"?
On the subject of 'Closures as Objects', here's a package that implements
closures as objects, including inheritance, AUTOLOADING and SUPER::.
Abigail
package OO::Closures;
################################################################################
#
# $Author: abigail $
#
# $Date: 1998/10/01 22:54:57 $
#
# $Id: Closures.pm,v 1.1 1998/10/01 22:54:57 abigail Exp abigail $
#
# $Log: Closures.pm,v $
# Revision 1.1 1998/10/01 22:54:57 abigail
# Initial revision
#
#
#
################################################################################
use vars qw /$VERSION/;
($VERSION) = '$Revision: 1.1 $' =~ /(\d+.\d+)/;
sub import {
my $my_package = __PACKAGE__;
my $foreign_package = caller;
my $my_sub = 'create_object';
shift;
my $foreign_sub = @_ ? shift : $my_sub;
no strict 'refs';
*{"${foreign_package}::$foreign_sub"} = \&{"${my_package}::$my_sub"};
}
sub croak {
require Carp;
goto &Carp::croak;
}
sub create_object {
my ($methods, $ISA, $is_base) = @_;
sub {
my ($method, @args) = @_;
my ($call_super, $class);
if ($method =~ /^([^:]+|:[^:])*::(.*)/s) {
$class = $1;
$method = $2;
}
return $methods -> {$method} -> (@args) if exists
$methods -> {$method} && !defined $class;
my @supers;
if (defined $class && ($class ne 'SUPER' || exists $ISA -> {$class})) {
unless (exists $ISA -> {$class}) {
croak "No class ($class) found\n";
}
@supers = ($ISA -> {$class});
}
else {@supers = values %$ISA}
foreach my $super (@supers) {
if (wantarray) {
my @tmp;
eval {@tmp = $super -> ($method => @args)};
return @tmp unless $@;
}
elsif (defined wantarray) {
my $tmp;
eval {$tmp = $super -> ($method => @args)};
return $tmp unless $@;
}
else {
eval {$super -> ($method => @args)};
return unless $@;
}
croak $@ unless $@ =~ /No such method/;
}
unless ($is_base) {
# This is the base class. So, we'll look for AUTOLOAD.
return $methods -> {AUTOLOAD} -> ($method => @args) if exists
$methods -> {AUTOLOAD} && !defined $class;
# my @supers;
# if (defined $class &&
# ($class ne 'SUPER' || exists $ISA -> {$class})) {
# @supers = ($ISA -> {$class})
# }
# else {@supers = values %$ISA}
# Check %ISA for AUTOLOAD.
foreach my $super (@supers) {
if (wantarray) {
my @tmp;
eval {@tmp = $super -> (AUTOLOAD => $method, @args)};
return @tmp unless $@;
}
elsif (defined wantarray) {
my $tmp;
eval {$tmp = $super -> (AUTOLOAD => $method, @args)};
return $tmp unless $@;
}
else {
eval {$super -> (AUTOLOAD => $method, @args)};
return unless $@;
}
croak $@ unless $@ =~ /No such method/;
}
}
croak "No such method ($method) found";
}
}
1;
__END__
=pod
=head1 NAME
OO::Closures - Object Oriented Programming using Closures.
=head1 SYNOPSIS
use OO::Closures;
sub new {
my (%methods, %ISA, $self);
$self = create_object (\%methods, \%ISA, !@_);
...
$self;
}
=head1 DESCRIPTION
This package gives you a way to use Object Oriented programming using
Closures, including multiple inheritance, C<SUPER::> and autoloading.
To create the object, call the function C<create_object> with three
arguments, a reference to a reference of a hash containing the method
of the object, a reference to an array containing the inherited
objects, and a flag determining whether the just created object is
the base object or not. This latter flag is important when it comes
to trying C<AUTOLOAD> after not finding a method.
C<create_object> returns a closure which will act as the new object.
Here is an example of the usage:
use OO::Closures;
sub dice {
my (%methods, %ISA, $self);
$self = make_object (\%methods, \%ISA, !@_);
my $faces = 6;
$methods -> {set} = sub {$faces = shift;};
$methods -> {roll} = sub {1 + int rand $faces};
$self;
}
It is a simple object representing a die, with 2 methods, C<set>, to set
the number of faces, and C<roll>, to roll the die. It does not inherit
anything. To make a roll on a 10 sided die, use:
(my $die = dice) -> (set => 10);
print $die -> ('roll');
Note that since the objects are closures, method names are the first
arguments of the calls.
=head1 INHERITANCE
To use inheritance, we need to set the C<%ISA> hash. We also need to
pass ourselves to the classes we inherited, so an inherited class can
find the base object. (This is similar to the first argument of the
constructor when using regular objects).
Here is an example that implements multi dice, by subclassing C<dice>.
We will also give C<dice> a method C<print_faces> that prints the number
of faces and returns the object.
use OO::Closures;
sub dice {
my (%methods, %ISA, $self);
$self = create_object (\%methods, \%ISA, !@_);
my $this_object = shift || $self;
my $faces = 6;
$methods {set} = sub {$faces = shift};
$methods {roll} = sub {1 + int rand $faces};
$methods {print_faces} = sub {print "Faces: $faces\n"; $this_object};
$self;
}
sub multi_dice {
my (%methods, %ISA, $self);
$self = create_object (\%methods, \%ISA, !@_);
my $this_object = shift || $self;
%ISA = (dice => dice $this_object);
my $amount = 1;
$methods {amount} = sub {$amount = shift};
$methods {roll} = sub {
my $sum = 0;
foreach (1 .. $amount) {$sum += $self -> ('dice::roll')}
$sum;
};
$self;
}
my $die = multi_dice;
$die -> (set => 7);
$die -> (amount => 4);
print $die -> ('print_faces') -> ('roll'), "\n";
__END__
Notice the line C<my $this_object = shift || $self;>. That will make
C<$this_object> contain the base object, unlike C<$self> which is the
instance of the current class.
The class C<dice> is subclassed in C<multi_dice> by calling C<dice>
with an extra argument, the base object. Now it's known that C<dice>
is subclassed, and looking for C<AUTOLOAD> if it cannot find the
requested method should not happen; that will be triggered by the
base object.
Inherited classes are named, but they are named by the inheriter,
not the inheritee. This allows you to inherit the same class multiple
times, and getting separate data and method space for it.
When searching for methods in the inheritance tree, no order will be
garanteed. If you subclass multiple classes defining the methods with
the same name, it's better to mask those methods and explicitely
redirect the call to the class you want it to handle.
You can call a method by prepending its class name(s); just like
regular objects.
Inherited classes are stored in the C<%ISA> hash, but since this variable
is private to the object, each object can have its own inheritance
structure. If you change a class, existing objects of the class will not
be modified.
The pseudo class 'SUPER::' works the same way as regular objects do,
except that it works the right way. It will resolve 'SUPER::' depending
on the inherited classes of the object the method is called in; not
on the C<@ISA> of the package the call is made from.
=head1 C<use OO::Closures;>
By default, the module C<OO::Closures> exports the function C<create_object>.
If you want this function to be known by another name, give that name
as an argument to the C<use> statement.
use OO::Closure 'other_name';
Now you create objects with C<other_name (\%methods, \%ISA, !@_);>
=head1 BUGS
This documentation uses the word 'class' in cases where it's not really
a class in the sense of the usual object oriented way.
=head1 HISTORY
$Log: Closures.pm,v $
Revision 1.1 1998/10/01 22:54:57 abigail
Initial revision
=head1 AUTHOR
This package was written by Abigail.
=head1 COPYRIGHT
This package is distributed under the Artistic License.
=cut
--
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 29 May 1999 18:05:06 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: localtime problems...
Message-Id: <slrn7l0t2d.7ub.abigail@alexandra.delanet.com>
dave (webmaster@geeks404.com) wrote on MMLXX September MCMXCIII in
<URL:news:7ggqqq$5kic$1@newssvr04-int.news.prodigy.com>:
\\ thank you! that's exactly what was the problem. but is there any way to get
\\ the full year i.e. 1999 vs. 99?
Not with the current Perl. But Perl6 will have addition!
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 29 May 1999 20:51:22 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: London.pm Meeting
Message-Id: <7ipk0a$31e$1@gellyfish.btinternet.com>
On Fri, 28 May 1999 06:36:43 GMT Dave Cross wrote:
>
> 1/ The results of Dave, Greg and Dave's "let's think up the stupidest
> set of rules to a Perl programming competition possible whilst heavily
> underthe influence of alcohol" competition (assuming, of course, that
> anyone bothered to enter).
>
I didnt understand a word of it so I guess that I can confirm that they
were indeed 'heavily under the influence of alcohol'.
However any Perl Hacker who lives or works or can be in London on the
day and who has thus far failed to embarrass themselves in the aforementioned
venue should come along and feel free to buy me a beer ;-}
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 30 May 1999 08:16:31 +0930
From: spamfree@metropolis.net.au (Henry Penninkilampi)
Subject: Re: MacPerl - ping other hosts
Message-Id: <spamfree-3005990816310001@d5.metropolis.net.au>
In article <1834C803DS86.PETER@yaleads.ycc.yale.edu>,
PETER@yaleads.ycc.yale.edu wrote:
>Hi. I was wondering if anyone could help me in figuring out how to
>ping other Macintosh hosts from MacPerl. All Macs are running OT.
>I seem to be able to ping some Unix hosts, but all Macs appear to be
>unreachable. ?
This is not an issue with MacPerl. There needs to be an active responder
on a Mac if you want it to respond to an ICMP packet (ping). OT doesn't
do this, by default.
Try running MacTCP Watcher on one of the target machines, then ping it,
and you'll get a response.
If you want them to be be 'pingable' all the time, you need to hunt down
some extension/control panel/faceless background app which responds to
pings.
Henry.
------------------------------
Date: 29 May 1999 18:32:04 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Making executables from .pl files?
Message-Id: <slrn7l0ul1.7ub.abigail@alexandra.delanet.com>
ralawrence@my-dejanews.com (ralawrence@my-dejanews.com) wrote on MMLXXV
September MCMXCIII in <URL:news:7guaqj$pa8$1@nnrp1.deja.com>:
\\
\\ If you wrote
\\ an inpressive encryption/decription system then you might not want to hand
\\ out the source code.
An encryption/description system _without_ source is meaningless, and
certainly not at all impressive.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 29 May 1999 19:28:10 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Newsfeed and Local Weather
Message-Id: <slrn7l11u6.7ub.abigail@alexandra.delanet.com>
John Klassa (klassa@aur.alcatel.com) wrote on MMLXXI September MCMXCIII
in <URL:news:7gk5tm$5sl$1@aurwww.aur.alcatel.com>:
|| On 02 May 1999 00:01:51 -0400, Uri Guttman <uri@sysarch.com> wrote:
|| > reading it. caps do help in some ways but i think more white space in
|| > perl would help too (like before ; tom?). that is my opinion on a style
||
|| You want to put whitespace before semicolons, as in:
||
|| print "foo\n" ;
||
|| (rather than just: print "foo\n";)?
||
|| Yikes.
The professor who introduced us to programming had the habit to put
the semicolons at the beginning of statements, not at the end. (This
was Pascal, where a semicolon is a statement _separator_, not a statement
terminator). This leads to code like:
statement
; statement
; statement
One of the benefits according to him is that it makes it harder to omit
a semicolon as that would be immediate obvious from the layout.
Perhaps he had a point.
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
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 5830
**************************************