[17996] in Perl-Users-Digest
Perl-Users Digest, Issue: 156 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 27 09:05:32 2001
Date: Sat, 27 Jan 2001 06:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <980604309-v10-i156@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 27 Jan 2001 Volume: 10 Number: 156
Today's topics:
Re: 'apply' function in perl? (Mark Jason Dominus)
.htpasswd crypt and dbm. (apache authentication) <nathan@nathanward.com>
Re: .htpasswd crypt and dbm. (apache authentication) <kistler@gmx.net>
Re: Calling rsync with "system" does not work (Otto Wyss)
Re: Calling rsync with "system" does not work (Otto Wyss)
Re: Calling rsync with "system" does not work (Otto Wyss)
Re: Calling rsync with "system" does not work (Martien Verbruggen)
Re: Comparing multiple values <nospam@nospam.com>
Converting a CSV file to a array <marc.beck@bigfoot.com>
Re: database <mellouet.ronan@wanadoo.fr>
Email Forwarding in Perl (D Unsworth)
Re: html link on perl created dynamic webpage <rosie@dozyrosy.plus.com>
Re: Internal Server Error- Newbie Question. <leekembel@hotmail.com>
loops and arrays <littlepaws@my-deja.com>
Re: More efficient than split? (Mark Jason Dominus)
Re: New way to learn Perl? <leekembel@hotmail.com>
Re: OOP: How to point/reference on a Class? (Martien Verbruggen)
Re: OOP: How to point/reference on a Class? (Mark Jason Dominus)
Re: perl editors (Martien Verbruggen)
Re: perl editors (Otto Wyss)
Perl for Windows applications: when <m_ario@my-deja.com>
Receive email with attachments <antios@libero.it>
Sendmail::Milter (Per Steinar Iversen)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 27 Jan 2001 10:43:39 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: 'apply' function in perl?
Message-Id: <3a72a65b.54cb$45@news.op.net>
In article <3a71ed40$1@news.microsoft.com>, Jürgen Exner <juex@deja.com> wrote:
>"Greg Bacon" <gbacon@HiWAAY.net> wrote in message
>news:t73mn8ubgc3f3@corp.supernews.com...
>> What are you? Some kinda anti-loopite? :-) mjd wrote[*] a Perl
>> version of reduce, and you could use that:
>>
>> my @nums = (1, 5, 14, 17, 7, -2);
>> my $sum = reduce { $a + $b } 0, @nums;
>>
>> If only Perl had curried functions... :-)
>
>Out of curiosity: would it be possible to somehow use closures for this
>purpose (or am I way off)?
>
You are right on the button. The reduce function Greg was alluding to
looks like this:
sub reduce (&$@) {
my $code = shift;
local $a = shift;
for (@_) {
local $b = $_;
$a = &$code;
}
$a;
}
But it's easy to make a curried version:
sub reduce (&$@) {
my $code = shift;
my $r1 = sub {
my $id = shift;
my $r2 = sub {
local $a = $id;
for (@_) {
local $b = $_;
$a = &$code;
}
$a;
};
return @_ ? $r2->(@_) : $r2;
};
return @_ ? $r1->(@_) : $r1;
}
Now you can call
reduce { $a + $b } 0, (1,4,2,8,5,7);
as before (it returns 27) but you can also call
$sum = reduce { $a + $b } 0;
and you get back a function which, when invoked as
$sub->(1,4,2,8,5,7)
returns 27.
Hmm, another example for my book. Thanks.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Sat, 27 Jan 2001 23:11:46 +1300
From: "Nathan Ward" <nathan@nathanward.com>
Subject: .htpasswd crypt and dbm. (apache authentication)
Message-Id: <4qxc6.1435$4a.62783612@news.xtra.co.nz>
I am probably going to get shot for this, but it is an area where perl
programmers will have knowledge, and I am using perl for this.
Ok, I am making a website that will have a large user-base. So users have to
be able to automaticly sign up etc.
I am using apache
Several questions:
1 - Is there any info or examples on using the crypt() function to help
generate .htpasswd files.
2 - I have seen info on using DBM and DB files, can someone please point me
to some information on this? the apache documention is very thin.
--
Nathan Ward
#########################################################################
# ICQ: 11899975 MSN Passport: daork1@hotmail.com #
# Email: nathan@nathanward.com Mob: +64 21 1285456 #
# #
# The contents of this email are private and confidential #
#########################################################################
------------------------------
Date: Sat, 27 Jan 2001 13:49:08 +0100
From: Per Kistler <kistler@gmx.net>
Subject: Re: .htpasswd crypt and dbm. (apache authentication)
Message-Id: <3A72C3C4.4A24E6BE@gmx.net>
Nathan Ward wrote:
> 1 - Is there any info or examples on using the crypt() function to help
> generate .htpasswd files.
crypt it with crypt('text','salt'); # text is the passwd, salt are two
random
letters.
> 2 - I have seen info on using DBM and DB files, can someone please point me
> to some information on this? the apache documention is very thin.
dbm from perl with dbmopen() etc. see perldoc -f dbmopen or search
all about it in the perldocu with perldoc perltoc and grep for dbm
Per.
--
Per Kistler, Zurich, Switzerland
------------------------------------------------------------------------
------------------------------
Date: Sat, 27 Jan 2001 11:40:25 +0100
From: otto.wyss@bluewin.ch (Otto Wyss)
Subject: Re: Calling rsync with "system" does not work
Message-Id: <1enw3yz.ztn8ze15rw3nkN%otto.wyss@bluewin.ch>
> > @args=("rsync", "-aPv --include-from .listfile", "$serverdir",
> > "$workdir");
>
> Either use a single string (without shell metacharacters), or split the
> list up correctly. In your case, the whole string "-aPv --include-from
> .listfile" gets passed to rsync as a single argument, instead of the
> three separate ones that it should get.
>
> @args = (qw(-aPv --include-from .listfile), $serverdir, $workdir);
> my $rc = system("rsync", @args);
>
Why are you useing qw(...) instead of "..."?
> If you use a single string, and there are no shell metacharacters, the
> splitting up on whitespace will happen automatically for you.
>
Does this mean that in my solution perl adds any metacharacters between
option "-aPv --include-from .listfile" and "$serverdir"... or anywhere
else? Why isn't it shown in the print statement? And why does rsync
complain about wrong "--" where there isn't any ? This is definitly not
obviously. Perl should handle it the way an ordinary programmer thinks
it should especially since it works in my first example.
O. Wyss
------------------------------
Date: Sat, 27 Jan 2001 11:40:25 +0100
From: otto.wyss@bluewin.ch (Otto Wyss)
Subject: Re: Calling rsync with "system" does not work
Message-Id: <1enw5c6.1a35emk1pxifukN%otto.wyss@bluewin.ch>
> > @args=("rsync", "-aPv", "$serverdir", "$workfile");
> > print "@args\n";
> > system (@args);
> > the following statement in script "mirrorsync"
> > @args=("rsync", "-aPv --include-from .listfile", "$serverdir",
> > "$workdir");
>
> Without actually testing, I don't like the above.
>
> There are really two different ways to call system.
> 1 arg
> >1 arg
>
> With 1 arg, the argument is broken up into multiple command line
> arguments and executed.
> With >1 arg, it assumes *you* have already broken everything up.
>
> I'm assuming that you want "-aPv" and "--include-from" to be separate
> arguments. By placing them within the same scalar and passing multiple
> arguments to system, they are not. They are a single argument with a
> space inside.
>
> Either break up all your arguments, or join them all together and just
> pass a scalar to system.
>
I have first tried splitting up all the arguments and only changed to
the current solution after getting the unrecognized option error.
O. Wyss
------------------------------
Date: Sat, 27 Jan 2001 11:40:25 +0100
From: otto.wyss@bluewin.ch (Otto Wyss)
Subject: Re: Calling rsync with "system" does not work
Message-Id: <1enw5k8.yafc3p1a538yzN%otto.wyss@bluewin.ch>
> > @args=("rsync", "-aPv --include-from .listfile", "$serverdir",
> > "$workdir");
> > print "@args\n";
> > system (@args);
> > produces allways the error "illegal option --".
>
> Either it's all one string for the shell, or then the command and
> each option have to be separate scalars, so that perl can start
> the command itself and hand over to it each argument. But the line
> above mixes up the two methods.
>
I know everthing in one string does work, splitting up doesn't. There is
definitly something wrong in the comunication between perl and rsync
(see my other posts).
O. Wyss
------------------------------
Date: Sat, 27 Jan 2001 22:27:33 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Calling rsync with "system" does not work
Message-Id: <slrn975c54.v2s.mgjv@martien.heliotrope.home>
On Sat, 27 Jan 2001 11:40:25 +0100,
Otto Wyss <otto.wyss@bluewin.ch> wrote:
>> > @args=("rsync", "-aPv --include-from .listfile", "$serverdir",
>> > "$workdir");
>>
>> Either use a single string (without shell metacharacters), or split the
>> list up correctly. In your case, the whole string "-aPv --include-from
>> .listfile" gets passed to rsync as a single argument, instead of the
>> three separate ones that it should get.
>>
>> @args = (qw(-aPv --include-from .listfile), $serverdir, $workdir);
>> my $rc = system("rsync", @args);
>>
> Why are you useing qw(...) instead of "..."?
qw() splits the string given up by whitespace and generates a list. The
above is equivalent to
@args = ("-aPv", "--include-from", ".listfile", $serverdir, $workdir);
This means that the splitting of the arguments gets done the same way a
shell would do it. By whitespace.
>> If you use a single string, and there are no shell metacharacters, the
>> splitting up on whitespace will happen automatically for you.
>>
> Does this mean that in my solution perl adds any metacharacters between
> option "-aPv --include-from .listfile" and "$serverdir"... or anywhere
> else? Why isn't it shown in the print statement? And why does rsync
No. It doesn't. What happens is that what you used above is the
equivalent of typing
rsync "-aPv --include-from .listfile" $serverdir $workdir
at your shell prompt. This causes the whole first quoted bit to be
passed as the first argument to rsync, instead of each part of it as a
separate argument. Most programs don't deal with that very well, and
rsync in particular doesn't understand it that way. It expects those to
be separate arguments.
> complain about wrong "--" where there isn't any ? This is definitly not
This is just the symptom rsync displays when you do this wrong. Just
type this in at a shell prompt:
$ rsync "-apv --include-from .listfile" foo bar
and observe the exact same error. If you omit the quotes, the error goes
away.
(my version of rsync doesn't have a -P option, so I'm assuming you meant
-p)
> obviously. Perl should handle it the way an ordinary programmer thinks
> it should especially since it works in my first example.
No. Perl should handle it as documented. Perl is not a shell, it's a
programming language. Perl's system() is modelled on the system command
as it exists on Unix systems (which is extended from the C libraries
system()), and on Unix systems, system() works like that. It forks, and
invokes one of the exec*(2) functions with the arguments.
The whole thing about metacharacters means that IF you hand system() a
single string, and not a list, and IF that string doesn't contain shell
metacharacters, Perl (or the underlying libraries) will split it up on
whitespace (like qw() does), and it will use the resulting list. IF it
contains shell metacharacters, a shell will be invoked, and the whole
string will be passed to the shell. So
system("ls -lF");
is equivalent to
system("ls", "-lF");
but
system("ls -lF > /tmp/foo");
is NOT equivalent to
system("ls", "-lF", ">", "/tmp/foo");
because in the second case there won't be a shell involved, and > and
/tmp/foo will be passed to ls as the 2nd and 3rd arguments.
This really isn't rsync misbehaving, it's just that you need to
understand what goes on when you invoke a program from your shell, and
correctly translate that into a call from system().
The following program works absolutely fine for me, in duplicating the
directory structure under /tmp/foo in /tmp/bar and /tmp/baz:
#!/usr/local/bin/perl -w
use strict;
my $rsync = '/usr/local/bin/rsync';
my @args = qw(-apv --recursive --include-from .listfile);
my $from = '/tmp/foo/';
my $to = '/tmp/bar/';
my $to2 = '/tmp/baz/';
system($rsync, @args, $from, $to);
system("rsync @args $from $to2");
You can see I used both a single string and a list. Both are fine. A
mixture isn't.
Give it a try. And, do read the documentation I pointed to, if you
haven't already. It basically says a lot of the same stuff I say in
here.
Martien
--
Martien Verbruggen |
Interactive Media Division | We are born naked, wet and hungry.
Commercial Dynamics Pty. Ltd. | Then things get worse.
NSW, Australia |
------------------------------
Date: 27 Jan 2001 09:33:33 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: Comparing multiple values
Message-Id: <94u4ld$dlo$0@216.155.32.147>
In article <m3ofwunsoi.fsf@mumonkan.sunstarsys.com>, Joe Schaefer
<joe+usenet@sunstarsys.com> wrote:
| nickco3@yahoo.co.uk (Nick Condon) writes:
|
| > abigail@foad.org (Abigail) wrote in
| > <slrn972idl.q5.abigail@tsathoggua.rlyeh.net>:
| >
| > >Craig Berry (cberry@cinenet.net) wrote on MMDCCIV September MCMXCIII
| > >in
| > ><URL:news:t719n74kcfuv79@corp.supernews.com>:
| > >'' datastar@my-deja.com wrote:
| > >'' : I can say:
| > >'' :
| > >'' : if ($somevar==3) { } # do something
| > >'' :
| > >'' : ...but what if I want to test if $somevar equals 3,4,8 or 9?
| > >''
| > >'' if (grep { $_ == $somevar } qw(3 4 8 9)) {
| > >''
| > >
| > > unless ($x ** 4 - 24 * $x ** 3 + 203 * $x ** 2 - 708 * $x + 864)
| > > {
| > > ... }
| > >
| > >which can be optimized to:
| > >
| > > unless (((($x - 24) * $x + 203) * $x - 708) * $x + 864) { ... }
| >
| > LOL!
| >
| > You've got way too much time on your hands.
|
| Is it really that hard to factor (x-3)(x-4)(x-8)(x-9) ?
|
| Besides, the more relevant issue is the optimized version,
| since that displays the standard technique for evaluating
| polynomials efficiently via computer.
|
| See section 5.3 of _Numerical Recipes in C_ for details.
I watched this whole entire thread unfold and saw absolutely NO ONE
respond to Damien Conway's extremely useful suggestion, therefore I
reiterate:
perl -MCPAN -e shell
cpan> readme Quantum::Superpositions
cpan> install Quantum::Superpositions
cpan> q
-=-
#!/usr/bin/perl -w
use strict;
use Quantum::Superpositions;
...
if ( $somevar == any(3,4,8,9) ) {
#do something here
}
...
is easily the clearest and most readable solution proposed in this
thread.
YMMV
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Sat, 27 Jan 2001 14:32:27 +0100
From: "Marc Beck" <marc.beck@bigfoot.com>
Subject: Converting a CSV file to a array
Message-Id: <94uil9$eoap6$1@ID-23826.news.dfncis.de>
Hello,
I got CSV file from my PIM and want to convert it to a SQL table.
Every field containing a value is sourrounded by "" and each one is
separated by a , .
i.e.:
"field1","field2","field3","field4"
"somevalue1","somevalue2",,"somevalue4"
I want to create a hash where the keys contain the column description
from the first line and the values are references to array containing
the corresponding column.
My problem is that I can't figure out exactly how to separate each row
and put the field values into an array.
Method 1:
@fields_of_row = split(/,/, $row);
and then cutting the surrounding "" off.
Problem with this method is when a field contains a ,
Method 2:
removing leading and trailing " from $row
then do
@fields_of_row = split(/","/, $row);
Problem with this method is when a field is empty (look at the example
I gave).
Method 3:
That's the one I couldn't figure out.
Your suggestions?
cu Marc
P.S.: I couldn't find a module with CPAN that does this job. Is there
one?
------------------------------
Date: Fri, 26 Jan 2001 11:03:28 +0100
From: "mellouet.ronan" <mellouet.ronan@wanadoo.fr>
Subject: Re: database
Message-Id: <94u1s0$3gf$1@wanadoo.fr>
Ok,
I don't succeed anymore.
the program doesn't recognizee the database.
I've try this sub program more simple :
sub init_words {
open (WORDLIST, "wordlist.txt")|| die "couldn't open wordlist: $!";#this
line is the problem,
#I've try a few solution :
#open(WORDLIST,"wordlist").....or
#$filename='wordlist.txt';open(WORDLIST,"$filename");
while ($name=<WORDLIST>){
chomp ($name);
$word=<WORDLIST>;
chomp ($word);
$word{$name}=$word;
}
close (WORDLIST)||die "could't close wordlist: $!";
}
Dirk Bernhardt <nospam@krid.de> wrote in message
news:94ont7$7bt$1@nets3.rz.RWTH-Aachen.DE...
> I don't know the book, but...
>
> mellouet.ronan <mellouet.ronan@wanadoo.fr> wrote:
> > sub init_words {
> > while ( defined($filename=glob("*.secret")) ){
> Look here -----------------------------^^^^^^^^
> That matches all files in your current working directory ending with
'.secret'.
>
> > open (WORDLIST, $filename)|| die "couldn't open wordlist: $!";
> > if(-M WORDLIST<7.0) {
> >
> > while ($name=<WORDLIST>){
> > chomp ($name);
> > $words=<WORDLIST>;
> typo? ---------------^
> Should be '$word', or?
>
> > So the problem is for read the database wordlist : I' don't know wich
> > name I should give to it. The program doesn't recognize it. I've tried
> > "wordlist.txt" and "wordlist" but it doesn't work. The database is in
the
> > same directorie of my program Hello.pl.
>
> Try e.g. "wordlist.secret".
>
> HTH,
> Krid
------------------------------
Date: Sat, 27 Jan 2001 13:27:10 GMT
From: dun@druwmg.u-net.com (D Unsworth)
Subject: Email Forwarding in Perl
Message-Id: <3a72cc69.2642228@news.u-net.com>
Hi
I am looking for a Perl script which will allow me to foward an email
with attachments to several other email addresses. Any help will be
most welcome.
Thanks
Dave Unsworth
------------------------------
Date: Sat, 27 Jan 2001 11:20:01 -0000
From: Rosemary I H Powell <rosie@dozyrosy.plus.com>
Subject: Re: html link on perl created dynamic webpage
Message-Id: <MPG.14dcbf401b2964a2989774@usenet.plus.net>
In article <94sfou$5dn$1@nnrp1.deja.com> dated Fri, 26 Jan 2001 18:30:53
GMT, our revered colleague davidmonroe@my-deja.com (davidmonroe@my-
deja.com) was so kind as to advise ...
> I'm new to Perl and am having difficulty putting a link in a page that was
> generated by a Perl script. This is what I have and it does not work.
>
> print "\n<a href="http://www.atgl.spear.navy.mil/feedback/trnofmod.htm">View
> your submission here</a><br>";
>
> Any help would be greatly appreciated.
>
> Dave
>
Look at the pattern of your quotes:
print ***"\n<a ref="***
http://www.atgl.spear.navy.mil/feedback/trnofmod.htm
***">View your submission here</a><br>"***;
They are gettting Perl in a pickle... Try instead:
print qq[print "\n<a
href="http://www.atgl.spear.navy.mil/feedback/trnofmod.htm">View
your submission here</a><br>];
Or read up about HERE documents.
HTH,
Rosemary
--
----------------------------------------------------------------
| Rosemary I.H.Powell EMail: Home: rosie@dozyrosy.plus.com |
| Work: r.i.h.powell@rl.ac.uk |
| http://NeedleworkSamplers.com/ |
| http://www.dozyrosy.plus.com/ |
| http://www.CavalierKingCharles.com/ |
----------------------------------------------------------------
------------------------------
Date: Sat, 27 Jan 2001 12:34:11 GMT
From: "Studio 51" <leekembel@hotmail.com>
Subject: Re: Internal Server Error- Newbie Question.
Message-Id: <7fzc6.4$c_1.13548@news4.rdc1.on.home.com>
"JCDixon" <jcdixon@aol.com> wrote in message
news:20010126190913.03811.00002566@ng-md1.aol.com...
> I am having trouble with a Perl script that is returning the same error;
i.e.
> "premature end of script headers" - an error for which there is no
Try putting this as the second line in your script:
print "Content-type: text/html\n\n";
If you still see the error then your script is failing on BEGIN, and there's
probably a pretty good description of it in your web server's error log.
LKembel
------------------------------
Date: Sat, 27 Jan 2001 12:24:17 GMT
From: Little Paws <littlepaws@my-deja.com>
Subject: loops and arrays
Message-Id: <94uelg$mab$1@nnrp1.deja.com>
I have an array. I want to display it a 'page' at a time (and do some
processing on it as well).
The idea is to access $pagesize items starting at $startindex, but
stopping if you run off the end of the array ($numentries is just
scalar @array)
Currently I have a loop that looks like this
for ($i=$startindex; $i < ($startindex + $pagesize < $numentries ?
$startindex + $pagesize : $numentries ); $i++) {
# do stuff with $array[$i]
}
Can anyone offer me a neater way?
--
()
() __ ()
/ \
\__/
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sat, 27 Jan 2001 10:30:55 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: More efficient than split?
Message-Id: <3a72a35e.5483$34d@news.op.net>
In article <3A71F10C.57709AC9@home.com>,
Michael Carman <mjcarman@home.com> wrote:
>Optimizing split() doesn't
>do that -- it's just a point solution -- which means that should be one
>of the last things you try, if at all.
And perhaps more to the point, 'split' is already optimized.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Sat, 27 Jan 2001 12:50:46 GMT
From: "Studio 51" <leekembel@hotmail.com>
Subject: Re: New way to learn Perl?
Message-Id: <Guzc6.6$c_1.23430@news4.rdc1.on.home.com>
<jqcordova@my-deja.com> wrote in message news:94sqbc$flf$1@nnrp1.deja.com...
> about it as you may find it useful too. If you could provide some
> feedback and maybe even submit a quiz or two through the site, it would
> be highly appreciated.
QUESTION: How would you initialize an array @a of length 100 to have all
values equal -1.
(a) for( $i=0; $i < 100; $i++ ) {$a[$i] = -1};
(b) @a = (-1) x 100;
(c) @a = map {-1} @a;
I answered (a), even though the ';' is misplaced, but I was wrong (according
to the quiz anyway). So I hit back and tried the other 2 answers, but they
were both wrong as well. After that I decided either the quiz was rigged, or
I don't know as much about Perl as I thought I did.
There were a few other questions that wouldn't accept any answer as well.
LKembel
------------------------------
Date: Sat, 27 Jan 2001 20:44:05 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: OOP: How to point/reference on a Class?
Message-Id: <slrn975635.v2s.mgjv@martien.heliotrope.home>
On Sat, 27 Jan 2001 08:31:25 +0100,
Oliver Söder <soeder@ai-lab.fh-furtwangen.de> wrote:
> Does a class have an own pointer type or do you just use a
> hash reference for a blessed hash etc.?
A blessed reference can be a reference to anything. A blessed hash
reference is most commonly used, but array and scalar references are
used as well[1].
There are no pointers in Perl, only references (and yes, they are
somewhat different). What makes a reference useable for Perl's OO
mechanism is the blessing.
The perlmod, perlref, perlobj, perltoot and perlbot manual pages explain
all this, and the entry for bless() in the perlfunc documentation
explains a bit as well.
If you're interested in this, Damian Conway's /Object Oriented Perl/
does a good job of talking about (almost?) all aspects of OO techniques
for Perl.
Martien
[1] Two examples that I know of: the GD package uses blessed scalars,
and Image::Magick uses blessed array references.
--
Martien Verbruggen |
Interactive Media Division | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use
NSW, Australia | being a damn fool about it.
------------------------------
Date: Sat, 27 Jan 2001 10:46:22 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: OOP: How to point/reference on a Class?
Message-Id: <3a72a6fd.54d8$169@news.op.net>
In article <3A72794D.1E4AA0E5@ai-lab.fh-furtwangen.de>,
Oliver =?iso-8859-1?Q?S=F6der?= <soeder@ai-lab.fh-furtwangen.de> wrote:
>Does a class have an own pointer type or do you just use a
>hash reference for a blessed hash etc.?
Just use a string:
$class = 'HTML::Parser'
represents the class 'HTML::Parser'.
$class->new(...)
will then call the 'new' method from that class.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Sat, 27 Jan 2001 20:46:08 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: perl editors
Message-Id: <slrn975670.v2s.mgjv@martien.heliotrope.home>
On 27 Jan 2001 04:59:36 GMT,
Rich Lafferty <rich@bofh.concordia.ca> wrote:
> In comp.lang.perl.misc,
> Kevin Michael Vail <kevin@vaildc.net> wrote:
>> In article <94np7f$483$1@nnrp1.deja.com>, hanja <hanja@my-deja.com>
>> wrote:
>>
>> > Out of curiousity, what editor do you use to write your scripts?
>>
>> On Unix: vi
>> On Windoze: UltraEdit
>> On MacOS: BBEdit
>
> So comPLEX! :-)
>
> On Unix: emacs
> On Windows: emacs
> On MacOS: emacs
>
> Extrapolate as necessary.
emacs is not an editor. It's a universe.
Unix: vim
Windows: vim
MacOS: vim
Extrapolate as necessary.
Martien
--
Martien Verbruggen |
Interactive Media Division | life ain't fair, but the root
Commercial Dynamics Pty. Ltd. | password helps. -- BOFH
NSW, Australia |
------------------------------
Date: Sat, 27 Jan 2001 11:53:06 +0100
From: otto.wyss@bluewin.ch (Otto Wyss)
Subject: Re: perl editors
Message-Id: <1enw64g.17ugx5vfvgdb8N%otto.wyss@bluewin.ch>
Kevin Michael Vail <kevin@vaildc.net> wrote:
> In article <94np7f$483$1@nnrp1.deja.com>, hanja <hanja@my-deja.com>
> wrote:
>
> > Out of curiousity, what editor do you use to write your scripts?
>
> On Unix: vi
> On Windoze: UltraEdit
> On MacOS: BBEdit
>
Almost as me
On Unix: vim => usable but I'm still not happy
On Windows: Wordpad => dito Unix
On MacOS: BBEdit => phantasic (remarks: I haven't done any Perl on
MacOS)
I'd really like to hav BBEdit (Lite) on all systems!
O. Wyss
------------------------------
Date: Sat, 27 Jan 2001 11:32:14 GMT
From: Mario <m_ario@my-deja.com>
Subject: Perl for Windows applications: when
Message-Id: <94ubjv$kim$1@nnrp1.deja.com>
Is a visual environment of Perl on the road? Something like borland c++
builder to be short.
I have read of a Microsoft Visual Perl beta version.
--
Mario
diab.litoATusa.net
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sat, 27 Jan 2001 13:51:00 GMT
From: "Antonio" <antios@libero.it>
Subject: Receive email with attachments
Message-Id: <8nAc6.35853$ew1.2597868@news.infostrada.it>
Hi all!
I'm searching a perl module that allow me to send and receive email with
attachments.
I have searched on cpan.org but i don't find that module!
Help me,
Antonio
------------------------------
Date: 27 Jan 2001 13:41:30 GMT
From: PerSteinar.Iversen@adm.hioslo.no (Per Steinar Iversen)
Subject: Sendmail::Milter
Message-Id: <slrn975jtv.do6.PerSteinar.Iversen@elbonia.p52.hio.no>
I am trying to write a virus filter for a mailhub using Sendmail::Milter
as downloaded from http://sourceforge.net/projects/sendmail-milter/
The filter runs on a RedHat 7 machine, the Perl rpm has been modified
by adding the -Dusethreads and -Duseithreads flags.
The filter is based on the sample.pl filter from Sendmail::Milter, nearly
all modifications have been made in the eom_callback routine. This
routine is called at the end of each message, my filter unpacks the
MIME structures and decodes and checks them using external programs
(reformime to unpack, a commercial virus checker etc.)
This works very well, the filter blocks a lot of infected messages,
worms etc. The problem is that is also sometimes block innocent messages
that arrive at exactly the same time as a virus... This is probably due
to some problem associated with threading. From reading various news
postings I get the feeling that threading in Perl 5.6.0 is perhaps not
good enough for this purpose - is that actually true?
-psi
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 156
**************************************