[17411] in Perl-Users-Digest
Perl-Users Digest, Issue: 4831 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 7 14:05:40 2000
Date: Tue, 7 Nov 2000 11:05:16 -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: <973623915-v9-i4831@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 7 Nov 2000 Volume: 9 Number: 4831
Today's topics:
ANNOUNCE: DBD::Sybase 0.90 <mpeppler@peppler.org>
ANNOUNCE: Expect 1.08 rgiersig@my-deja.com
Copy of directory tree <casades@uol.com.br>
Re: do you know why this doesn't work? <jeff@vpservices.com>
Re: Double fork trick: why does grandkid avoid becoming <ddunham@redwood.taos.com>
Re: Emailing formatted <abaltd@ntlworld.com>
Re: HELP Winows NT Mail::Sender <stevej@proact.net>
Re: Help with ActiveState PerlSvc (WinNT) <harasty@my-deja.com>
Re: Help! Can't use "next LABEL" in SIG{ALRM} sub nobull@mail.com
Re: Help! Can't use "next LABEL" in SIG{ALRM} sub <a@b.c>
MS SQL & Perl <RichParker@fssi-ca.com>
Re: MS SQL & Perl nobull@mail.com
Re: MS SQL & Perl <RichParker@fssi-ca.com>
Re: Need suggestions on optimization <newspost@coppit.org>
Re: Need suggestions on optimization <newspost@coppit.org>
Re: OOP and information hiding <ren.maddox@tivoli.com>
Re: OOP and information hiding (Chris Fedde)
Re: pass by reference to C <tim@ipac.caltech.edu>
Re: Passing Hash to Perl Module Update <james@NOSPAM.demon.co.uk>
Re: Passing Hash to Perl Module Update <ren.maddox@tivoli.com>
Perl/CGI 入學指南 <answer@hotmail.com>
Re: Problem reading a binary file <james@NOSPAM.demon.co.uk>
Processing a URL input (BUCK NAKED1)
Q: Can't locate integer.pm in @INC jonasroden@my-deja.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 06 Nov 2000 13:11:40 -0800
From: Michael Peppler <mpeppler@peppler.org>
Subject: ANNOUNCE: DBD::Sybase 0.90
Message-Id: <3A071E8C.3D81CD50@peppler.org>
The uploaded file
DBD-Sybase-0.90.tar.gz
has entered CPAN as
file: $CPAN/authors/id/M/ME/MEWP/DBD-Sybase-0.90.tar.gz
size: 58363 bytes
md5: b06e4d29a5348c7ed86526614fbf5c85
Why the version number change (the previous version was 0.23) ?
I now feel that DBD::Sybase is becoming solid, so this is a Beta
release, with the intention of releasing 1.00 sometime this
winter. I've gone through and checked lots of details, such as nested
transaction handling in AutoCommit off mode, type_info() data and
various other problems that people have reported, and I think the
behavior is now more consistent.
Here's the CHANGES record for this release:
Release 0.90
Release number sequence change: I'm dropping the "alpha" qualifier
and I expect to release 1.00 fairly soon.
Small Makefile.PL fix for Sybase 12.0 installation directory
changes.
Applied patch from Tim Ayers to allow 0x type formatting for
binary data fetches (similar to what Sybase::CTlib and
Sybase::DBlib allow).
Fixed some t/ scripts to not fail when run against MS-SQL.
Corrected the handling of timeout events in the client
callback.
Bug Fixes:
349: CS_NUMERIC bindings for ?-style placeholders fails for large
values.
345: Dynamic statement ids get re-used.
351: prepared statements with placeholders cause handle to become
unusable if *first* execute fails.
352: ping() doesn't work right in Apache::DBI (thanks to
Kiriakos Georgiou)
353: syb_quoted_identifier doesn't work.
354: Calling fetch() after prepare() but no execute() fails with
internal DBI error. This should also fix bug # 278 and 288.
297: type_info() returns incorrect or no data.
344: timeout doesn't work correctly.
Michael
--
Michael Peppler - Data Migrations Inc. - mpeppler@peppler.org
http://www.mbay.net/~mpeppler - mpeppler@mbay.net - AIM MPpplr
International Sybase User Group - http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com
------------------------------
Date: Tue, 07 Nov 2000 10:57:44 GMT
From: rgiersig@my-deja.com
Subject: ANNOUNCE: Expect 1.08
Message-Id: <8u8n77$5m6$1@nnrp1.deja.com>
There is a new version of Expect.pm available at CPAN and also at the
projects page on Source Forge
(http://sourceforge.net/projects/expectperl/).
There are two mailing lists there, one for announcement of new
versions and one for general discussion. There is also a bug tracking
system in place.
I have taken over maintainance and development from Austin Schutz and
intend a complete rewrite somewhen in the future. I'm also in the
progress of taking over the IO::Tty module from Graham Barr, which
makes sense, as Expect is probably the main (only?) user of IO::Tty.
I have already received several support requests that concern problems
with pty creation on various platforms. Unfortunately, this is a
system configuration issue that should be handled by your friendly
sysadmin. But I do intend to gather a FAQ regarding this issues, so I
would like to encourage all users that can contribute to this to join
the discussion mailing list. Please, send your problem reports
regarding pty creation there. It may take a while until an answer
might come up, but hey, you get what you pay for it...
Roland <RGiersig@cpan.org>
Changes from v1.07:
New multi-match interface (shaped after the TCL version):
It's now possible to expect on more than one connection at a time by
specifying '-i' (see the TCL expect manpage for semantics) and a ref
to an array containing Expect objects.
Furthermore, patterns can now be specified as array refs containing
`[$regexp, sub { ...}, @optional_subprams]'. When the pattern
matches, the subroutine is called with parameters
($matched_expect_obj, @optional_subparms). The subroutine can return
the symbol `exp_continue' to continue the expect matching with timeout
starting anew or return the symbol `exp_continue_timeout' for
continuing expect without resetting the timeout count.
Example:
expect($timeout,
'-i', [ $obj1, $obj2, ... ],
[ $re_pattern, sub { ...; exp_continue; },
@subparms, ],
[ 'eof', sub { ... } ],
[ 'timeout', sub { ... }, \$subparm1 ],
'-i', [ $objn, ...],
'-ex', $exact_pattern, sub { ... },
$exact_pattern, sub { ...; exp_continue_timeout; },
'-re', $re_pattern, sub { ... },
'-i', \@object_list, @pattern_list,
);
--
RGiersig@cpan.org
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 07 Nov 2000 17:59:14 GMT
From: Andre <casades@uol.com.br>
Subject: Copy of directory tree
Message-Id: <8u9ftb$pll$1@nnrp1.deja.com>
I want to make a copy of a directory tree (including files). The first
solution to do this is call system(cp -r) for Linux and system(xcopy /R)
for Windows but I like to make a perl script that run in both OS.
Does anyone know a good and clean way to do this?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 07 Nov 2000 08:38:07 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: do you know why this doesn't work?
Message-Id: <3A082FEF.D725FD7B@vpservices.com>
Garry Williams wrote:
>
> On Mon, 06 Nov 2000 20:16:49 -0800, Jeff Zucker <jeff@vpservices.com>
> wrote:
> > my $p=Net::Ping->new($protocol);
>
> Of course, that's exactly what I posted after the bit you quoted.
<temporary blindness> Yes, you did didn't you. </temporary blindness>
Sorry for being redundant.
--
Jeff
------------------------------
Date: Tue, 07 Nov 2000 18:28:34 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: Double fork trick: why does grandkid avoid becoming a zombie?
Message-Id: <mRXN5.19365$Wq1.9237647@nnrp5-w.sbc.net>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> Mark-Jason Dominus <mjd@plover.com> wrote in comp.lang.perl.misc:
>>It is in an infinite loop waiting for one of its adopted children to
>>die; when one does, init cleans up the corpse immediately. In fact,
>>that's the primary function of init.
> Well, I'd say it's the secondary (and only) function of init after
> its primary function (bringing up the system processes) is done.
I can't leave well enough alone...
What init actually does depends on the system. SYSV variants have an
inittab that init is responsible for. Init may restart daemons that die
due to the file, and of course it handles changing run states.
If you ever run into a system where init is *not* reaping inherited dead
children, look for an error in the /etc/inittab. I've seen a machine
with an error there that caused init to be so (uselessly) busy that it
stopped reaping.
--
Darren Dunham ddunham@taos.com
Unix System Administrator Taos - The SysAdmin Company
Got some Dr Pepper? San Francisco, CA bay area
< Please move on, ...nothing to see here, please disperse >
------------------------------
Date: Tue, 7 Nov 2000 16:13:14 -0000
From: "abaltd" <abaltd@ntlworld.com>
Subject: Re: Emailing formatted
Message-Id: <GTVN5.55191$mv2.203160@news2-win.server.ntlworld.com>
Thanks James,
I have now had some success with simply HTML - but not yet with multipart...
James Taylor <james@NOSPAM.demon.co.uk> wrote in message
news:ant06173006cfNdQ@oakseed.demon.co.uk...
> You don't need sendmail to understand the formatting of a MIME message
> body, whether multipart or otherwise. As long as sendmail can read what
> it needs from the standard headers, it does not need to concern itself
> with the body of the message. You seem to already have it reading To:
> and CC: lines (and I assume From:) so it should work.
That was the basis of my thinking: just "pretend" that it came from a
MIME-formatted message...
i.e. include:
From: alan.dougall@virgin.net
Subject: Hello there
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_C0_KBO0LAAA"
(and so on)
> If you are still having problems, then perhaps there is something else.
> Are you using sendmail's -oi option?
No, normally just sendmail -t !!
(checking man sendmail: -oi ignores '.'s at beginning of lines??)
> Have you constructed the MIME message correctly using the MIME::Tools
perhaps?
No, I'm just embedding HTML code similar to the content of just any ol'
formatted email that I have received (in Outlook Express)
Can I assume that the MIME::Tools library will already be on the ASP's host
server?
> What are the symptoms of it not working?
Looking at the message source of the resultant email, I notice there is a
X-UIDL after the Content-Type which is interfering with the boundaries
between the text and HTML parts. When I remove the multipart/alternative
and text/plain part, then it's fine. But I didn't think that just HTML was
acceptable for some email recipients.
The resultant multipart email is:
Return-Path: revivaln
Received: (from revivaln@localhost)
by vs11.virtualisys.com (8.9.3/8.9.3) id HAA15374;
Tue, 7 Nov 2000 07:50:22 -0800 (PST)
Date: Tue, 7 Nov 2000 07:50:22 -0800 (PST)
Message-Id: <200011071550.HAA15374@vs11.virtualisys.com>
To: alan.dougall@virgin.net
Subject: Hello Tony
From: alan.dougall@virgin.net
Mime-Version: 1.0
Content-Type: multipart/alternative;
X-UIDL: 7a3fcf819829b439ac9097840d9bd4b4
boundary="----=_NextPart_000_C0_KBO0LAAA"
------=_NextPart_000_C0_KBO0LAAA
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Simple text here: Hello there
------=_NextPart_000_C0_KBO0LAAA
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<html>
<body bgcolor=white link=333399 vlink=333399 alink=333399>
<table align=center width=300 border=2 bgcolor=d6d7f0 cellpadding=5
cellspacing=0>
<tr><td>
<font face=Verdana color=teal size=2>This is a formatted <b>test</b>
message!</font>
</td></tr>
</table>
</body></html>
------=_NextPart_000_C0_KBO0LAAA--
--
Alan Dougall
alan.dougall@virgin.net
http://start.at/the.cross
------------------------------
Date: Tue, 7 Nov 2000 16:13:35 -0000
From: "Steve Jones" <stevej@proact.net>
Subject: Re: HELP Winows NT Mail::Sender
Message-Id: <3a0830db_1@nnrp1.news.uk.psi.net>
I use sender.pm on NT. I locate it as follows (ignore GNU Unix cmds):
$ pwd
c:/perl/lib/Mail
$ ls
Address.pm Field Header.pm Mailer.pm Send.pm
Alias.pm Field.pm Internet.pm MessageList.pm Sender.pm
Cap.pm Filter.pm Mailer POP3Client.pm Util.pm
$
In the script, I say
require 5.002;
#
# Includes
#
use Mail::Sender;
#---- globals --
"Paulgee" <paul.g@cableinet.co.uk> wrote in message
news:CJLN5.9882$aT1.924969@news3.cableinet.net...
> Hi all
> I am trying to get script.pl to send mail from a NT server it has
> activestate installed but perl cannot find the dir where sender.pm is
> installed, is the answer to push another search location onto the @INC
array
> and if so can anyone tell me the default directory or a clue where
sender.pm
> is usualy installed.
>
> I wanted to check that I am not missing something before I contact my ISP.
>
> thanks
>
> paul
>
> p.s
> I am using the following from cpan.
> use Mail::Sender;
>
> $sender = new Mail::Sender {smtp => 'mail.yourdomain.com', from =>
> 'your@address.com'};
> $sender->MailFile({to => 'some@address.com', subject => 'Here is
the
> file',
> msg => "I'm sending you the list you wanted.",
> file => 'filename.txt'});
>
>
>
>
>
------------------------------
Date: Tue, 07 Nov 2000 18:17:17 GMT
From: Dan Harasty <harasty@my-deja.com>
Subject: Re: Help with ActiveState PerlSvc (WinNT)
Message-Id: <8u9gv3$qp0$1@nnrp1.deja.com>
In article <8t5l6q$e1r$1@nnrp1.deja.com>,
Dan Harasty <harasty@my-deja.com> wrote:
> The example from the docs seems to "build" fine (actually running
> PerlSvc) but after installing the service (with the NtResKit's "sc")
> command, the service doesn't seem to start.
OK, I'll partly answer my own post for those who come after me. (Two
more weeks of fiddling has been somewhat successful.)
Firstly: You don't need to install the service in "the usual way" with
"InstSrv" or "sc". (I don't know if trying this was part of my problem
or not.) Just run the PerlSvc-created exe with the "-install"
commandline and it installs itself. Use "-remove" to uninstall the
service.
Nextly: I was basing a simple app on the sample code, which declared a
"package main" below the "package PerlSvc" code. In the Startup loop,
I made calls into functions in "main", but forgot to preface them with
"main::". (Duh...) Use something like this:
sub Startup {
# here's where your startup code will go
main::Init();
while(ContinueRun()) {
main::LogIt(localtime()."\n") unless (time() % 30);
sleep(1);
}
}
As for this:
> Also: the example from the docs is ambiguous on the use of
> "ContinueRun". Is this a function or a scalar?
The answer is it is a function as the sample code shows, and apparently
the "PerlSvc" framework fills in code for this call...
OK - now with the simple stuff working, time to add in the "hard stuff":
my real code!
- Dan Harasty
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 07 Nov 2000 17:53:09 +0000
From: nobull@mail.com
Subject: Re: Help! Can't use "next LABEL" in SIG{ALRM} sub
Message-Id: <u9y9yvhdoa.fsf@wcl-l.bham.ac.uk>
"Kingsley Tart" <a@b.c> writes:
> I'm trying to abort a loop on timeout with a SIG alarm but it won't use my
> label. I've simplified the code here for testing purposes but the essense of
> the SIG alarm is the same:
>
> #!/usr/bin/perl
> $counter=1;
> CHECK: while ( $counter > 0 )
> {
> print "Trying ...\n";
> $SIG{ALRM} = sub { print "timed out\n"; next CHECK; };
> alarm (5);
> $counter--;
> sleep (10);
> }
> print "normal exit ...\n";
>
>
> I was hoping that during the sleep statement, the SIG alarm would cause that
> copy of the loop to finish and go back to the label but it doesn't recognise
> the label, see below:
Two problems here:
1) You can't goto (or next, last, redo, continue) out of a signal
handler. The only "approved" Perl way to do the equivalent of a
POSIX/C siglongjmp() is eval{}/die() (see "perldoc perlipc" for
details)
2) Don't mix sleep() and with $SIG{ALRM}/alarm() on some platforms sleep() is
implemented using alarm().
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 7 Nov 2000 18:31:51 -0000
From: "Kingsley Tart" <a@b.c>
Subject: Re: Help! Can't use "next LABEL" in SIG{ALRM} sub
Message-Id: <%UXN5.82964$hk2.210380@news6-win.server.ntlworld.com>
> Two problems here:
>
> 1) You can't goto (or next, last, redo, continue) out of a signal
> handler. The only "approved" Perl way to do the equivalent of a
> POSIX/C siglongjmp() is eval{}/die() (see "perldoc perlipc" for
> details)
Hmm, that presents me with a problem. I need to check whether various
hosts are accepting connections on a particular TCP port. On certain
hosts, this fails quite quickly if they are not but on some it goes on for
ages (20 mins or so) and this is causing other problems. So, I wanted
to set a 1 minute timeout on the connect and continue the program
whether it connects or not. This is the actual code I am using:
if (socket (TESTSOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp')))
{
if (connect (TESTSOCK, sockaddr_in($defaultport,
$HostToTestIPAddr)))
{
$Connected=1;
close (TESTSOCK);
}
}
Is the only way of doing this to for a subprocess to do the connection test?
Actually, I've just tried putting "close(TESTSOCK)" into the alarm sub and
that seems to force the connect to fail - perhaps this is the way I should
do
it. Forking another process is expensive because this is a big program and
this check will happen a lot.
> 2) Don't mix sleep() and with $SIG{ALRM}/alarm() on some platforms sleep()
is
> implemented using alarm().
I'm not in the real application, I only did this to make testing easy.
Cheers,
Kingsley.
------------------------------
Date: Tue, 07 Nov 2000 18:13:13 GMT
From: Rich Parker <RichParker@fssi-ca.com>
Subject: MS SQL & Perl
Message-Id: <3A084758.4296BB49@fssi-ca.com>
Hi,
First, I have been coding Perl for sometime and don't really consider
myself a newbie at this kind of stuff.
Here's what I am having some troubles with:
1) The Terminology of 'mSQL' or 'mysql', is either of these a mask for
MS SQL? None of the many docs I have read address this in a way that
makes this 'Crystal clear' to me.
2) I am running a plain vanilla WinNT 4.0 server with SQL 7.0 and Perl
5.0. For the life of me my
'my $dbh = DBI->connect($plist, $username, $psw) ...' is not working and
I've tried many, many different combinations for the variables. This
makes me ponder one other question: Did this stuff load correctly (DBI
and/or ODBC)?? The 'perl makefile.pl' worked just fine, but the 'make'
or 'nmake' gets an unknown command type of msg. What is the key to these
(DBI & ODBC)? Do these belong in certain directories/folders?
I think if I can get a handle on these 2 issues, I'll be 'Rocking &
rolling' on the SQL path. It's either that, or scrap the WinNT (IIS)
idea and restart everything and somehow do all this on Linux (Causing
even more delays).
Please shed some light for me on this...
Thanks ahead of time....
--
Rich Parker
Web Sites:
Business: http://www.fssi-ca.com
Personal: http://southcoastdivers.com
E-mail:
Business: mailto:RichParker@fssi-ca.com
Personal: mailto:Rich@southcoastdivers.com
------------------------------
Date: 07 Nov 2000 18:22:00 +0000
From: nobull@mail.com
Subject: Re: MS SQL & Perl
Message-Id: <u9wvefhcc7.fsf@wcl-l.bham.ac.uk>
Rich Parker <RichParker@fssi-ca.com> writes:
> Here's what I am having some troubles with:
> 1) The Terminology of 'mSQL' or 'mysql', is either of these a mask for
> MS SQL?
No.
> 2) I am running a plain vanilla WinNT 4.0 server with SQL 7.0 and Perl
> 5.0.
5.0? You are running 5.0!?
> For the life of me my
> 'my $dbh = DBI->connect($plist, $username, $psw) ...' is not working and
> I've tried many, many different combinations for the variables. This
> makes me ponder one other question: Did this stuff load correctly (DBI
> and/or ODBC)??
Dunno, is $dbh defined? Did you get any errors.
> The 'perl makefile.pl' worked just fine, but the 'make'
> or 'nmake' gets an unknown command type of msg. What is the key to these
> (DBI & ODBC)? Do these belong in certain directories/folders?
I recommend getting Perl 5.6. I'd even recommend getting the
Activestate binary if you are running on NT.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 07 Nov 2000 18:56:48 GMT
From: Rich Parker <RichParker@fssi-ca.com>
Subject: Re: MS SQL & Perl
Message-Id: <3A085192.76A50CED@fssi-ca.com>
Sorry 'bout that, it is the latest Perl from ActiveState, I downloaded it
about a week ago.
The main problem here is when the DBI line is executed, nothing at all comes
back, so nothing displays. I have tried a 'DIE' when it fails and a call of a
subroutine that will display info and then die, neither way gets me anything.
It is very upsetting to debug just one line of code for more than 2 days.
More ideas???
nobull@mail.com wrote:
> Rich Parker <RichParker@fssi-ca.com> writes:
>
> > Here's what I am having some troubles with:
> > 1) The Terminology of 'mSQL' or 'mysql', is either of these a mask for
> > MS SQL?
>
> No.
>
> > 2) I am running a plain vanilla WinNT 4.0 server with SQL 7.0 and Perl
> > 5.0.
>
> 5.0? You are running 5.0!?
>
> > For the life of me my
> > 'my $dbh = DBI->connect($plist, $username, $psw) ...' is not working and
> > I've tried many, many different combinations for the variables. This
> > makes me ponder one other question: Did this stuff load correctly (DBI
> > and/or ODBC)??
>
> Dunno, is $dbh defined? Did you get any errors.
>
> > The 'perl makefile.pl' worked just fine, but the 'make'
> > or 'nmake' gets an unknown command type of msg. What is the key to these
> > (DBI & ODBC)? Do these belong in certain directories/folders?
>
> I recommend getting Perl 5.6. I'd even recommend getting the
> Activestate binary if you are running on NT.
>
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
--
Rich Parker
Web Sites:
Business: http://www.fssi-ca.com
Personal: http://southcoastdivers.com
E-mail:
Business: mailto:RichParker@fssi-ca.com
Personal: mailto:Rich@southcoastdivers.com
------------------------------
Date: Tue, 7 Nov 2000 12:28:17 -0500
From: David Coppit <newspost@coppit.org>
Subject: Re: Need suggestions on optimization
Message-Id: <Pine.GSO.4.21.0011071227400.5178-100000@mamba.cs.Virginia.EDU>
[posted & mailed]
On 6 Nov 2000, Ren Maddox wrote:
> > > Right here I start to get the feeling that you could define $/ as
> > > "\nFrom " and process a message at a time.
> >
> > Yeah, that dawned on me after I posted. I tried that, and got no
> > appreciable improvement. :(
>
> Mainly out of curiosity, what does the profiling show is taking the
> bulk of the time when you change to using $/ instead of the regex? Is
> it the readline?
Yep.
David
------------------------------
Date: Tue, 7 Nov 2000 12:44:50 -0500
From: David Coppit <newspost@coppit.org>
To: Eli the Bearded <elijah@workspot.net>
Subject: Re: Need suggestions on optimization
Message-Id: <Pine.GSO.4.21.0011051924150.16082-100000@mamba.cs.Virginia.EDU>
[posted & mailed]
On 3 Nov 2000, Eli the Bearded wrote:
> > if ($reversed !~ /^\n*[^\n]*?----- egasseM dedulcnI nigeB -----\n/i)
>
> How about using rindex to search for "Begin ..." from the end
> of the message?
Hm... Okay, I implemented that, also using rindex to check that the
position of the last newline after the "Begin Included Message" is the
last character in the string. That gave me about a 5% speedup for the
common case.
> What about reading line by line and searching for "Original Message"
> / "From ..." as you go along.
Great idea. Doing this didn't give me a speedup, unfortunately.
> If for some reason you can't or don't want to use the built-in input
> buffering, your buffer stuff could be used, but you should be using
> 'sysread' instead of 'read'.
Sorry... Can you elaborate? Is sysread faster?
--------------
In the end, I've decided to implement the mailbox reading stuff in C.
(Great time to learn XS!) This resulted in 32% speedup for the mailbox
reading task. Preliminary experiments with read/buffer code from GNU
grep indicate that this can be increased to 90%.
All this I/O optimization will eventually leave my main function as
taking 42% of the time, so I'll work on that. Of the remaining time,
half is used by core Perl modules, so I guess I'd be pushing the limit
of optimization at that point. ;)
For those of you interested, you can check out the XS-based module
Mail::Folder::FastReader, distributed with grepmail 4.44, which is
making its way out to CPAN now. This will become a separate module
once the interface is stable and the code is better optimized.
David
------------------------------
Date: 07 Nov 2000 10:54:18 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: OOP and information hiding
Message-Id: <m37l6fsoxx.fsf@dhcp11-177.support.tivoli.com>
abigail@foad.org (Abigail) writes:
> In the great Perl tradition of "do it all yourself, the language won't
> make it easy for you", the object is implemented as a hashref. You add
> your little 2 methods to the object, using one attribute to store data,
> and your module goes in production.
One might argue that you are explicitly bypassing the interface by
relying on the implementation being a hashref. But then, I suppose
your point is that you pretty much have to do this and that is the
problem.
I know that one of the solutions to this is to use package-named
attributes within the hash. Perhaps we need a better,
language-supported method of doing this. What about an implicit
package-scoping concept for instance attributes?
Actually, don't the "fields" and "base" pragmas pretty much provide
this safe-guard (thought without the package-scoping)?
It even has:
Field names that start with an underscore character are
made private to the class and are not visible to
subclasses. Inherited fields can be overridden but will
generate a warning if used together with the "-w" switch.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Tue, 07 Nov 2000 18:27:22 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: OOP and information hiding
Message-Id: <eQXN5.226$Bf7.189811200@news.frii.net>
In article <slrn90fvml.ctp.abigail@tsathoggua.rlyeh.net>,
Abigail <abigail@foad.org> wrote:
>
>Perls way of implementing OO is actually anti-OO, as it gives the
>user of the class (that is, the inheriting class) all the baggage
>of the implementation. Precisely what OO is *NOT* supposed to do.
>"Stick to the interface" should all that's needed to succesfully
>use objects. But in Perl, it's "stick to the implementation".
>
OK, I'll accept that hash as instance variable was short sighted.
What is the fix? Is it even possible to fix things now? Or will
fixing it break backward compatibility? Most of the CPAN classes
use this convention because that is what is recommended in the
documentation. Can we simply re-write perltoot and perlbot to
encourage a safer technique? Maybe we should adopt object as
closure as the recommended convention.
chris
--
This space intentionally left blank
------------------------------
Date: Tue, 07 Nov 2000 11:43:48 -0800
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: pass by reference to C
Message-Id: <3A085B74.272C85C3@ipac.caltech.edu>
vidulats@yahoo.co.uk wrote:
> #!/usr/bin/perl5
> use Datatypes;
>
> @y= ('12','34','56','90','345');
> foreach $x(@y)
> {
> cfunc ($x);
> }
>
> This is the code of XS file:
>
> void
> cfunc(x)
> char * x
>
> CODE:
> {
> int i;
> for(i=0;(*x) != '\0';i++,x++)
> {
>
> printf("%c\n",*x);
> }
> }
>
> This works perfectly OK.
>
> But, if I change the foreach loop. i.e. instead of
> foreach $x(@y)
> {
> cfunc ($x);
> }
>
> If I write
> cfunc(@y);
>
> then, it gives the error as
> Usage: Datatypes::cfunc(x) at datatypes.pl
Wow, you're using XS and you don't know the difference between passing $x and
@y? It's back to the man pages for you young man! :-)
cfunc is expecting a single scalar value and you're giving it many scalar values
by passing the array @y. cfunc($y[0]) would work fine. cfunc(@y) would work too
if @y has only one member.
--
-- Tim Conrow tim@ipac.caltech.edu |
------------------------------
Date: Tue, 7 Nov 2000 18:00:36 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Passing Hash to Perl Module Update
Message-Id: <ant0718360b0fNdQ@oakseed.demon.co.uk>
In article <8u8vro$vid$1@lublin.zrz.tu-berlin.de>, Anno Siegel
<URL:mailto:anno4000@lublin.zrz.tu-berlin.de> wrote:
>
[snip]
Thanks that makes it all clear.
> Camps are divided whether this kind of polymorphism is even desirable.
> Myself, I usually prefer to have separate object methods for cloning
> existing objects and not saddle new() with that task.
Agreed.
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: 07 Nov 2000 09:33:38 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Passing Hash to Perl Module Update
Message-Id: <m3lmuvssod.fsf@dhcp11-177.support.tivoli.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> Camps are divided whether this kind of polymorphism is even desirable.
> Myself, I usually prefer to have separate object methods for cloning
> existing objects and not saddle new() with that task.
Not that I expect to reconcile the divided camps, but it is easy to
imagine a situation where you want to create additional object of the
same type as an object you already have, without knowing the specific
class. Sure, you could interrogate the object to determine its class
and use that to call the constructor, but it seems cleaner to just let
polymorphism take care of that for you.
What are the arguments against having an instance method constructor?
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Wed, 8 Nov 2000 02:01:14 +0800
From: "問題" <answer@hotmail.com>
Subject: Perl/CGI 入學指南
Message-Id: <8u9gm9$63313@rain.i-cable.com>
http://easyto.heha.net/
本站提供Perl/CGI教學 ,Perl/CGI討論區歡迎前來提出你的問題
本站有許多高手到訪,想信您的問題一定能在本站找到滿意的
答覆^^
------------------------------
Date: Tue, 7 Nov 2000 18:06:53 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Problem reading a binary file
Message-Id: <ant0718531cbfNdQ@oakseed.demon.co.uk>
In article <3A080C67.A2A512FE@home.com>, Michael Carman
<URL:mailto:mjcarman@home.com> wrote:
>
> [Note: All of this is in the docs...]
Yes, sorry.
> Perl knows how to convert the platform's idea of "\n" to it's own
> internal representation. In reality, "\n" is *not* a character. Think of
> it as a "virtual newline character" which gets translated to/from the
> real newline sequence on I/O.
I don't understand what you mean by not really a character. Surely once
you have read a text file in (perhaps in slurp mode) you will have it
in memory (perhaps in a scalar) and each newline is represented by a
genuine linefeed character (ASCII 10). In what way is it not real?
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Tue, 7 Nov 2000 11:37:26 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Processing a URL input
Message-Id: <9823-3A083DD6-12@storefull-248.iap.bryant.webtv.net>
I wrote an HTML page that has a form where people input a URL, and then
click SUBMIT. This takes the URL that was input to my script.pl file for
processing.
In my script.pl file, I use LWP's getstore to grab the URL that was
input from the form file. Now, how do I get the URL that was input on
the form page to: 1) read in for processing and save to a temporary
file; and 2) how do I get the URL that was input in the form to print?
If it makes any difference, the URL's that are being input into the form
are binary files?
I've read all the perl docs many times for over a week now, and still
can't figure this
out. Any help would be appreciated.
Thanks,
Dennis
------------------------------
Date: Tue, 07 Nov 2000 16:39:32 GMT
From: jonasroden@my-deja.com
Subject: Q: Can't locate integer.pm in @INC
Message-Id: <8u9b83$kvq$1@nnrp1.deja.com>
I've installed perl using MSV C++ to C:\perl on an
w2000 system
Installation:
VCVARS32.BAT
#from the win32 direktory
nmake
nmake test
nmake install
I've uppdated the PATH with
c:\perl\bin;c:\perl\bin\MSWin32-x86
My problem is that I cant use any modules, for
example integer.
use integer;
I get the error "Can't locate integer.pm in @INC".
If @INC is printed using
print join("\n",@INC);
I get the result
..\lib\i386-win32
..\lib
.
Is there anything I've forgotten?
Please I need help
Thanks in advance / Jonas
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
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 V9 Issue 4831
**************************************