[19066] in Perl-Users-Digest
Perl-Users Digest, Issue: 1261 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 7 03:05:50 2001
Date: Sat, 7 Jul 2001 00:05:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <994489516-v10-i1261@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 7 Jul 2001 Volume: 10 Number: 1261
Today's topics:
[ANNOUNCE] Mail::MboxParser 0.01 <Tassilo.Parseval@post.rwth-aachen.de>
Re: Best way to pad a string with spaces?? <miscellaneousemail@yahoo.com>
FAQ: What is perl6? <faq@denver.pm.org>
HELP:didn't understood something with references... (Bruno Boettcher)
How can I join beginners@perl.org mailing list?? <miscellaneousemail@yahoo.com>
Re: How can I join beginners@perl.org mailing list?? <miscellaneousemail@yahoo.com>
Re: I know this must be in the manpages... number forma (Mike E)
Re: I know this must be in the manpages... number forma <pne-news-20010707@newton.digitalspace.net>
Re: Net::Telnet logging on problem..... <jwalker@warwick.net>
Re: Net::Telnet logging on problem..... <jwalker@warwick.net>
Re: problem with data.. <goldbb2@earthlink.net>
Re: Problems moving from an Apache server to a Windows <kerry@shetline.com>
Re: Regex problem: Multiple matches across Multiple lin <goldbb2@earthlink.net>
Re: Why for loop not working?? <pne-news-20010707@newton.digitalspace.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 05 Jul 2001 19:43:03 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: [ANNOUNCE] Mail::MboxParser 0.01
Message-Id: <tkd9tpgc7b2o89@corp.supernews.com>
NAME
Mail::MboxParser - read-only access to UNIX-mailboxes
SYNOPSIS
use Mail::MboxParser;
my $mb = Mail::MboxParser->new('some_mailbox');
for my $msg ($mb->get_messages) {
my %header = %{$msg->header};
print $msg->from->{name}, "\n";
print $msg->from->{email}, "\n";
print $header{subject}, "\n";
print $header{'reply-to'}, "\n";
$msg->store_all_attachements('/tmp');
}
DESCRIPTION
This module attempts to provide a simplified access to standard
UNIX-mailboxes. It offers only a subset of methods to get 'straight
to
the point'. More sophisticated things can still be done by invoking
any
method from MIME::Tools on the appropriate return values.
METHODS
The below methods refer to Mail::MboxParser-objects.
new
new(MAILBOX)
This creates a new MboxParser-object opening the specified MAILBOX
with
either absolute or relative path. It does not necessarily need a
parameter in which case you need to pass the mailbox to the object
using
the method 'open'. Returns nothing.
open(mailbox)
Can be used to either pass a mailbox to the MboxParser-object either
the
first time or for changing the mailbox. Returns nothing.
get_messages
Returns an array containing all messages in the mailbox respresented
as
Mail::MboxParser::Mail objects.
nmsgs
Returns the number of messages in a mailbox. You could naturally
also
call get_messages in an array context, but this one wont create new
objects. It just counts them and thus it is much quicker and wont
eat a
lot of memory.
The below methods refer to Mail::MboxParser::Mail-objects returned
by
get_messages.
new(header, body)
This is usually not called directly but instead by
$mb->get_messages.
You could however create a mail-object manually providing the header
and
body both as one string.
header
Returns the mail-header as a hash-ref with header-fields as keys.
All
keys are turned to lower-case, so $header{Subject} has to be written
as
$header{subject}.
body
Returns the body as a single string.
from
Returns a hash-ref with the two fields 'name' and 'email'. Returns
undef
if empty.
id
Returns the message-id of a message cutting off the leading and
trailing
'<' and '>' respectively.
num_entitities
Returns the number of MIME-entities. That is, the number of
sub-entitities actually.
get_entitities([n])
Either returns an array of all MIME::Entity objects or one
particular if
called with a number.
get_entity_body(n)
Returns the body of the n-th MIME::Entity as a single string.
store_entity_body(n, FILEHANDLE)
Stores the stringified body of n-th entity to the specified
filehandle.
That's basically the same as:
my $body = $mail->get_entity_body(0);
print FILEHANDLE $body;
and could be shortened to this:
$mail->store_entity_body(0, \*FILEHANDLE);
store_attachement(n, path)
It is really just a call to store_entity_body but it will take care
that
the n-th entity really is a saveable attachement. That is, it wont
save
anything with a MIME-type of, say, text/html or so. It uses the
recommend-filename found in the MIME-header. 'path' is the place
where
the new file will go to.
store_all_attachements(path)
Walks through an entire mail and stores all apparent attachements to
'path'. See the supplied store_att.pl script in the eg-directory of
the
package to see a useful example.
FIELDS
Mail::MboxParser is basically a pseudo-hash containing two fields.
$mb->{READER}
This is the filehandle from which is read internally. As to yet, it
is
read-only so you can't use it for writing. This may be changed
later.
$mb->{NMSGS}
Having called nmsgs once this field contains the number of messages
in
the mailbox. Thus there is no need for calling the method twice
which
speeds up matters a little.
Mail::MboxParser::Mail is a pseudo-hash with four fields.
$mail->{RAW}
Contains the whole message (that is, header plus body) in one
string.
$mail->{HEADER}
Well, just the header of the message.
$mail->{BODY}
You guess it.
$mail->{ENTITY}
The top-level MIME::Entity of a message. You can call any suitable
methods from the MIME::tools upon this object to give you more
specific
access to MIME-parts.
BUGS
Don't know yet of any. However, since I only have a limited number
of
mailboxes on which I could test the module, there might be
circumstances
under which Mail::MboxParser fails to work correctly. It will
probably
fail on mal-formated mails produced by some cheap CGI-webmailers.
The way of counting the number of mails in a mailbox is a little
suspect. Internally this looks like
$self->{NMSGS}++ if /^Lines:\d+\n$/
In case nmsgs really produces bogus then you could try calling
get_messages in scalar context:
$mb->{NMSGS} = $mb->get_messages
Once having done so, a call to nmsgs will produce
this number since it only parses once and will only return the
previously cached results on later calls.
AUTHOR AND COPYRIGHT
Tassilo von Parseval <Tassilo.Parseval@post.RWTH-Aachen.de>.
Copyright (c) 2001 Tassilo von Parseval. This program is free
software;
you can redistribute it and/or modify it under the same terms as
Perl
itself.
------------------------------
Date: Sat, 07 Jul 2001 05:09:31 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Re: Best way to pad a string with spaces??
Message-Id: <MPG.15b046ebd41d98bc98968f@news.edmonton.telusplanet.net>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <auv17.5407$bs2.646577@news20.bellglobal.com>,
qumsieh@sympatico.ca says...
>
> Again, you choose the easy way by posting a question rather than looking up
> the answer yourself. Writing the FAQs took up a huge amount of time from
> many dedicated individuals specifically to help other people find the
> answers themselves. Please attempt to consult them before posting. You'll
> make your life easier, and you might stumble upon other gems hidden in the
> docs (and believe me, there are a lot).
>
Hi Ala,
Thanks for your input again. I appreciate it. And yes the perldoc -q
pad does answer my question. Thanks for pointing that out. I did not
even know there was a perldoc -q or for that matter a perldoc -q pad. I
read through the perl FAQ several times and did not see anything in there
about padding (I must have missed it or was reading the wrong FAQ -
Manipulating Data).
I feel I must say something though about some of your comments above Ala.
There is no way in the world that I have taken the easy way out. I have
been spending countless hours and I mean countless hours trying to
understand how to work with Perl. I have been doing little more than
breathing, reading, and taking in Perl in the past few weeks. As a
result I have ended up with a lot of questions and as anyone who has been
on these newsgroups can see I have uploaded a lot of questions (and have
appreciated very much the answers I have been given).
Just so you know I have had countless more questions that I have answered
on my own.
In general I try hard to answer my own questions Ala and I have often
hesitated to ask a question on the newsgroups out of concern that I will
be seen as asking too many and that I will loose the good will of those
who give me answers. But I have weighed this concern against the need to
get an answer. When the answer eludes me after a fair and reasonable
effort to find it on my own I turn to the newsgroups. It's either keep
using Perl (with help from the newsgroups) or give it up. At times that
is the choice that I am confronted with because to do it the hard way
(completely on my own) is so time consuming as to make Perl programming
impractical.
I guess it is a matter of balance Ala. While I certainly agree that I
should not fire off a question the first time I have it without doing a
lot to find the answer on my own I also don't think it would be fair to
expect me to find so much out on my own that I never accomplish anything
with the language. I do have to make a living.
I would challenge anyone coming to Perl for the first time from whatever
background to find that there is a perldoc -q pad in less than an hour of
diligent searching and looking for things on padding. On their own.
Without any knowledge of what resources there are or even where those
resources are. Newbies like me sinply don't know where to look Ala.
It's like asking someone who is blind to go find a great fishing hole by
poking around for it. At best it's a hit or miss affair.
If I do indeed end up in the kill zone for asking too many questions I
will either have to give up Perl or find someplace else to ask my newbie
questions. I think there is another forum for newbies that just started
out. I just read about it today. Maybe I should hang out there.
Can I get input from others on this please? (not to discount any further
input from you Ala. I would very much like to hear any further input you
might have. Just that I want to get a feel for whether I am in the wrong
newsgroup as a newbie.) Am I asking too many questions?
--
Carlos
www.internetsuccess.ca
------------------------------
Date: Sat, 07 Jul 2001 06:17:00 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: What is perl6?
Message-Id: <wPx17.38$T3.188819456@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
What is perl6?
At The Second O'Reilly Open Source Software Convention, Larry Wall
announced Perl6 development would begin in earnest. Perl6 was an oft
used term for Chip Salzenberg's project to rewrite Perl in C++ named
Topaz. However, Topaz should not be confused with the nisus to rewrite
Perl while keeping the lessons learned from other software, as well as
Perl5, in mind.
If you have a desire to help in the crusade to make Perl a better place
then peruse the Perl6 developers page at http://www.perl.org/perl6/ and
get involved.
The first alpha release is expected by Summer 2001.
"We're really serious about reinventing everything that needs
reinventing." --Larry Wall
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
01.05
--
This space intentionally left blank
------------------------------
Date: 7 Jul 2001 07:11:26 GMT
From: bboett@erm6.u-strasbg.fr (Bruno Boettcher)
Subject: HELP:didn't understood something with references...
Message-Id: <9i6cmu$ch7$1@news.u-strasbg.fr>
hello,
struggling with references....
i have made an object:
package mailbox;
use baseactor;
use ObjectTemplate;
use POSIX qw(strftime);
@ISA = ("baseactor");
attributes("messages","deb");
sub PRIVMSGaction
{
my ($obj,$line) = @_;
my %settings = %{$obj->sysdata()};
@actMsg = @{$settings{$receiver}};
$now_string = strftime "%a %b %e %H:%M:%S %Y", gmtime;
$now_string .= " : ".$msg." by ".$sender."\n";
push(@actMsg,$now_string);
$settings{$receiver} = \@actMsg;
$obj->sysdata(\%settings);
return 1;
}#if($line =~ /.*:(\S+)!(\S+) PRIVMSG $botname :mail (.*)$/)īŠ
return 0;
}#sub PRIVMSGaction
but it doesn't behave as expected....
i can't get the refs to behave as refs... i allways get copies and the data i insert gt lost...
you may find the full example and there's a test.pl in:
http://erm1.u-strasbg.fr/~bboett/zebot.tgz
--
bboett at erm1 dot u-strasbg dot fr
http://erm6.u-strasbg.fr/~bboett
==============================================================
Unsolicited commercial email is NOT welcome at this email address
------------------------------
Date: Sat, 07 Jul 2001 05:40:11 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: How can I join beginners@perl.org mailing list??
Message-Id: <MPG.15b04e818e751957989691@news.edmonton.telusplanet.net>
Hi everyone,
I was reading an article today....
http://www.perl.com/pub/a/2001/05/29/tides.html
where a new mailing list for beginners was mentioned called
beginners@perl.org and I was wondering if anyone could fill me in on how
to join such a list?
Is it like a newsgroup in that you use a newsreader to access the posts
or more like getting all new posts coming into a mailbox?
Thanks
--
Carlos
www.internetsuccess.ca
------------------------------
Date: Sat, 07 Jul 2001 05:43:04 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Re: How can I join beginners@perl.org mailing list??
Message-Id: <MPG.15b04f2dc2be6112989692@news.edmonton.telusplanet.net>
In article <MPG.15b04e818e751957989691@news.edmonton.telusplanet.net>,
miscellaneousemail@yahoo.com says...
Never mind everyone. I looked up the mailing list through www.google.com
and found instructions for subscribing.
--
Carlos
www.internetsuccess.ca
------------------------------
Date: 07 Jul 2001 05:39:58 GMT
From: uthinkxxuthink@yahoo.com (Mike E)
Subject: Re: I know this must be in the manpages... number formatting
Message-Id: <slrn9kd8j7.9dc.uthinkxxuthink@srv01.datacenterops.com>
* Philip Newton <pne-news-20010706@newton.digitalspace.net> wrote:
> On 6 Jul 2001 22:07:54 +0200, elwood@news.agouros.de (Konstantinos
> Agouros) wrote:
>
>> I might be blind, but what I am looking for is some way to print larger integer
>> numbers with digits (german way) like
>> 1000000000 gets printed to 1.000.000.000 or with ,'s depending on the locale.
>
> Well, the basic idea is in `perldoc -q "commas added"`. Switching the
> decimal point/thousands comma to decimal comma/thousands point is as
> easy as tr/,./.,/ after wards.
>
> The "hard" bit is probably to determine the correct locale decimal
> separator and thousands separator. Perhaps you can pull something out of
[...]
Off the top of my head, it sounds like flipping the number around would
make this a trivial exercise.
me
--
$email =~ s/xx//;
------------------------------
Date: Sat, 07 Jul 2001 07:56:49 +0200
From: Philip Newton <pne-news-20010707@newton.digitalspace.net>
Subject: Re: I know this must be in the manpages... number formatting
Message-Id: <h19dktgacrd5u88alg3e6h75l4liu73a1t@4ax.com>
On 07 Jul 2001 05:39:58 GMT, uthinkxxuthink@yahoo.com (Mike E) wrote:
> * Philip Newton <pne-news-20010706@newton.digitalspace.net> wrote:
> > On 6 Jul 2001 22:07:54 +0200, elwood@news.agouros.de (Konstantinos
> > Agouros) wrote:
> >
> >> I might be blind, but what I am looking for is some way to print larger integer
> >> numbers with digits (german way) like
> >> 1000000000 gets printed to 1.000.000.000 or with ,'s depending on the locale.
> >
> > Well, the basic idea is in `perldoc -q "commas added"`. Switching the
> > decimal point/thousands comma to decimal comma/thousands point is as
> > easy as tr/,./.,/ after wards.
> >
> > The "hard" bit is probably to determine the correct locale decimal
> > separator and thousands separator. Perhaps you can pull something out of
> [...]
>
> Off the top of my head, it sounds like flipping the number around would
> make this a trivial exercise.
Your quoting makes it hard for me to determine which bit of my post
you're referring to. If you mean the "put thousands separators into a
number" bit, then yes, flipping the number around is one way to do it.
Another way is in the FAQ I alluded to.
If you mean the "determine the correct locale decimal separator and
thousands separator" (which it looks like, since it's the last thing you
quoted, immediately before your material), then I don't see how flipping
the number around would help determine that the decimal separator is '.'
in, say, England and ',' in, say, Germany.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Sat, 07 Jul 2001 00:50:53 -0400
From: John Walker <jwalker@warwick.net>
Subject: Re: Net::Telnet logging on problem.....
Message-Id: <3B46952D.9487535F@warwick.net>
Yas:
I'm way out of depth here, but I did have a similar
problem the solution for which might help you.
Assuming your login works, it looks to me as if you're
not waiting for the 'Iom>' prompt. You need to
insert something like:
# Wait for next prompt;
($reply) = $HOST->waitfor('/Iom>/');
before sending your @test response.
Hope this helps.
Clachair
Never lick a gift horse in the mouth.
------------------------------
Date: Sat, 07 Jul 2001 01:06:42 -0400
From: John Walker <jwalker@warwick.net>
Subject: Re: Net::Telnet logging on problem.....
Message-Id: <3B4698E1.F17C6011@warwick.net>
Yas wrote:
> Which to me seems stranger as there is no password prompt :(
I've found this too, and had to remove the password from the
usual login sequence. My login line simply reads:
$Telnethost->open("$username");
#Wait for menu prompt;
As Rickey says, pay strict attention to what the log files
contain, but also look at the command line logs if that's possible.
Also, a lot of telnet communication routines send ANSI codes
(Which you can get Perl to recognize!) despite being told not to.
Clachair
Never lick a gift horse in the mouth!
------------------------------
Date: Sat, 07 Jul 2001 00:39:42 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: problem with data..
Message-Id: <3B46928E.6DFDA4E8@earthlink.net>
Darren Dunham wrote:
>
> I've written a simplistic client/server program that tars up some
> files and sends them over an ssh connection. It works most of the
> time, but since I started testing it, I'm getting corrupted tar files
> out the other end some times. Once, I noticed that the last file in
> the archive had some data out of place, not just truncated.
>
> I'd like to know if anyone can see that what I'm doing is a fault of
> my perl calls or ssh or something...
>
> The client does this...
>
> my $cmd = "tar cf - .";
> print "$version\n";
> print `$cmd`;
>
> $version is just a text string to help the server validate the data.
If data is "out of place" within the archive, there's the possibility
that it's the tar command that's putting it in the wrong position in the
first place. Oh, and why do you capture the output and then send it on,
rather than letting tar send to your STDOUT directly?
my $cmd = "tar cf - .";
$| = 1;
print $version\n";
unless( system($cmd) == 0 ) {
my ($sig,$ret) = ( $? & 0xFF, $? >> 8 );
die "tar died from signal $sig\n" if $sig;
die "tar exited with code $ret\n" if $ret;
die "waitpid() failed unexpectedly: $!\n";
}
> The server opens a filehandle by calling ssh to client with a pipe.
>
> my $cmd = "$ssh -e none -n ${user}\@${host} $remote_cmd 2>&1";
> unless (open (SSH, "$cmd|"))
> {
> warn "$0: Could not open ssh connection to $host.\n";
> ...
open to/from a pipe fails iff the fork fails; whether or not the command
is there has little or no relevance. For instance:
open( FOO, "nosuchcommand|" )
will usually succeed. To test whether the command itself worked, you
have to look at the return value of close. Also, I would consider
putting redirection as seperate from the command itself:
my $cmd = "$ssh -e none -n $user\@$host $remote_cmd";
unless (open (SSH, "$cmd 2>&1|")) {
warn "$0: Fork failed for ssh command: $!\n";
...
} else {
...
unless( close(SSH) ) {
my ($sig,$ret) = ( $? & 0xFF, $? >> 8 );
warn "ssh died from signal $sig\n" if $sig;
warn "ssh exited with code $ret\n" if $ret;
warn "waitpid() failed unexpectedly: $!\n";
}
}
> And then the main thing in the open is..
>
> my $version = <SSH>;
> # ... section that validates the versioin string
> # ...
>
> $cmd = "$tar xf -";
> open (TAR, "|$cmd");
>
> # read from SSH and push to TAR...
> my $buf;
> my $blocksize = "16384";
> my $len;
> while ($len = read SSH, $buf, $blocksize)
> {
> if (!defined $len)
How can $len be true, but not defined? Oops :)
> {
> # whoops, some error occured.
> warn "$0: read error occured: $!\n";
> warn "$0: Skipping host $host.\n";
> close (TAR);
> close(SSH);
> next HOST;
> }
> print TAR $buf;
> }
> close (SSH);
> if ($?)
> { warn "$0: Status from SSH close was $?: $!\n"; }
> close(TAR);
> if ($?)
> { warn "$0: Status from TAR close was $?: $!\n"; }
>
> Because I wanted to quickly grab the version string off the front of
> the stream, I'm using <>, read, and print rather than sysread and
> syswrite. It could be a little slower, but nothing should get out of
> order or truncated if I read it right..
Personally, I would use sysread to grab the version string, then dup SSH
over STDIN, then call system.
my $v = "";
1 while( sysread( SSH, $v, 1, length $v ) && !chomp $v );
if( my $pid = fork ) {
if( waitpid($pid,0) == -1 ) {
my ($sig,$ret) = ( $? & 0xFF, $? >> 8 );
warn "tar died from signal $sig\n" if $sig;
warn "tar exited with code $ret\n" if $ret;
warn "waitpid() failed unexpectedly: $!\n";
}
unless( close SSH ) {
my ($sig,$ret) = ( $? & 0xFF, $? >> 8 );
warn "ssh died from signal $sig\n" if $sig;
warn "ssh exited with code $ret\n" if $ret;
warn "waitpid() failed unexpectedly: $!\n";
}
} elsif( defined $pid ) {
open STDIN, "<&SSH";
exec $cmd;
} else {
warn "Couldn't fork: $!";
sleep 10;
redo LABEL;
}
> When I run this, I sometimes get errors on a single host like this..
>
> running for calvin...
> tar: directory checksum error
> infoserver.pl: Status from TAR close was 512:
> running for hobbes...
> running for homer...
>
> Anyone see what (if anything) I've done wrong here? It smells like
> I'm truncating a buffer or not flushing something, but I don't see
> where that might be happening.
Are all your errors from calvin? Is it the same machinetype (unix vs
dos) as the one your server is running on? Consider what happens if you
tar up a file on calvin, ftp it to the host, then try untaring it... if
you use read/print, then perl is going to do CRLF conversions, while if
you let tar handle its input and output itself, this isn't a problem.
I realize that my fork/exec/wait code is more C-ish than perlish, but it
is usually best to check for errors as robustly as possible.
--
The longer a man is wrong, the surer he is that he's right.
------------------------------
Date: Sat, 07 Jul 2001 05:03:38 GMT
From: "Kerry Shetline" <kerry@shetline.com>
Subject: Re: Problems moving from an Apache server to a Windows server
Message-Id: <KKw17.2106$Pf6.1421921@typhoon.ne.mediaone.net>
"Wyzelli" <wyzelli@yahoo.com> wrote in message
news:w8t17.3$ji3.768@vic.nntp.telstra.net...
> "Kerry Shetline" <kerry@shetline.com> wrote in message
> news:xss17.1238$Pf6.1168455@typhoon.ne.mediaone.net...
> > What kinds of things can crash Perl and not even give you an error
> message?
> >
>
> Badly written code!
Matters of elegance and efficiency aside, just how badly written can the
code be if it has been running perfectly fine for many months already on an
Apache web server? If Perl code crashes a Perl compiler, isn't that the
fault of the compiler and not the code? A robust compiler should be able to
take random garbage as input, producing error messages as output without
crashing.
I realize that sometimes we have to live with the fact that our tools aren't
perfect and it often becomes our job to work around the bugs, but given that
the code I'm using has proved itself functional already in one enviroment,
I'd rather first look for known problems in the new environment where the
code doesn't run before I go hacking at functional code trying to guess what
contortions are necessary to side-step some as-yet unknown compiler bug.
> If you are having problems with a particular piece of code, the best
> solution is to narrow it down to as small as practical instance of
something
> that still demonstates the same problems and then post that here.
The way the Windows server is reacting it's very hard to narrow anything
down, because the scripts run fine some of the time, then produce absolutely
no output whatsoever at other times. No partial output. No error messages
delivered either to the web browser or the server logs.
> Otherwise it is all guesswork, and my PSI::ESP module is misbehaving
today.
> :)
I was hoping that once I decribed the symptoms, someone else out there would
have encountered a similar situation and might be able to say, "Oh yeah...
make sure you don't ever do X", or "Make sure your hosting service installs
patch Y for product Z".
I'm looking for any known fundamental differences between Perl on an Apache
server and Perl on a Windows server, or any known bugs in the Activestate
Perl used on the Windows web hosting service that I'm trying to use.
I've already found one basic difference: With Apache, my Perl CGIs need to
output the MIME type before any other output. On the Windows server, the
MIME type is automatically text/html, and I have to remove the code that
prints "Content-type: text/html\n\n", or else it appears as literal text in
my CGI output. (Who knows what I would do if I wanted to produce a different
MIME type?)
> There can be other issues with IIS 50, and it is a good idea to ensure
that
> you have all the latest patches, and the latest Perl from Activestate etc
> (5.6.1 is good) etc, but there are likely to be problems generated by
things
> like file lock or path problems which can't be diagnosed without seeing
the
> programs.
The strange thing is, it doesn't seem to have much of anything to do with
the particular programs. All of my different Perl CGIs work for a while,
from short and simple counters to more involved scripts, then suddenly none
of them work, and maybe a little while later, all of them work again.
-Kerry
------------------------------
Date: Sat, 07 Jul 2001 01:53:27 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Regex problem: Multiple matches across Multiple lines
Message-Id: <3B46A3D7.2609EA19@earthlink.net>
Ron Hill wrote:
>
> Hello All,
> I am trying to parse a document and am running into difficulty ( see
> test script below my post) If this script is run as is, it takes a
> long time to return and $11 var is empty. However if I comment out the
> lines (.*\n) and SYMPTOM after the HARDWARE line the script returns
> without a long wait and I have what I need in the vars $1 - $10.
> my question is How can I get the information between HARDWARE and
> SYMPTOM as var $11? And also continue on with the other information (
> var $12 contains the information between SYMPTOM and SOLUTION?
> Can anyone help me find out what I am doing wrong?
This seems to be an XYZ problem. You want X, the only way you can think
to do it is Y, so that's what you ask for, but what you really want to
knows is how to do Z.
>
> Thanks
>
> Ron
>
> undef $/;
> while (<DATA>) {
What's the point in doing a while, when there's only going to be one
value? After all, EOF generally only occurs once per stream.
local $_ = do { local $/; <DATA>; };
This causes $/ to be undef for the minimal time necessary, and sets it
back to the default afterwards (and sticks <DATA> in $_, but that should
be obvious). Also, remember that it's usually a good idea to make $_
local, rather than just assigning to it, for various and sundry reasons.
> /
You really ought to use an explicit m for match, and some character
other than /, except in fairly short regexs. If there's no / characters
in your pattern, it's ok, I guess, but [] often improve readability.
Put these subs somewhere sensible.
sub malf {
die "Malformed input at char # ".pos."\n";
}
sub get1 {
# uppercase $_[0], match&discard it,
# and capture the rest of the line (not including \n)
m[\G\U$_[0]:\s*(.*)\n]gc or malf;
$1;
}
sub get2 {
# uppercase $_[0] and $_[1], match and discard them
# and capture the two parts of the line, and avoiding
# any whitespace on the end of $1, due to *? and \s*
m[\G\U$_[0]:\s*(.*?)\s*$_[1]:\s*(.*)\n]gc or malf;
($1, $2);
}
sub getp {
# uppercase, match, and discard $_[0]
m[\G\U$_[0].*\n-*\n]gc or malf;
# save position.
my ($p,$res) = (pos, "");
# match lines up till we get an all uppercase line.
while( m[\G(.*\n)]gc && $1 !~ m[^[A-Z /]+$] ) {
$res .= $1; $p = pos;
}
# restore pos to just before the all uppercase line.
pos = $p;
return $res;
}
Then use them:
my $product = get1 "product";
my $subject = get1 "subject";
m[\G\n]g or malf; # discard newline
my ($by, $date) = get2 "submitted by", "submitted date";
my ($ir,$d_id) = get2 "ir #", "document id";
my ($plat, $os) = get2 "platform", "operating system";
my ($osv, $ugv) = get2 "os version", "ug version";
m[\G\n=*\n\n]g or malf; # discard newline, =, double newline.
my $hardware = getp "hardware";
my $symptom = getp "symptom";
my $solution = getp "solution";
my $reference = getp "reference";
--
The longer a man is wrong, the surer he is that he's right.
------------------------------
Date: Sat, 07 Jul 2001 07:32:03 +0200
From: Philip Newton <pne-news-20010707@newton.digitalspace.net>
Subject: Re: Why for loop not working??
Message-Id: <kj7dkt46tbsh94ste3npm65toe8bcvd402@4ax.com>
On Fri, 06 Jul 2001 20:54:03 -0700, "$Bill Luebkert" <dbe@wgn.net>
wrote:
> If @temp has 6 elements, $# is equal to 5
$#temp is equal to 5 [1]. $# is another (deprecated) variable.
> (the index of the last element of the array).
Cheers,
Philip
[1] (mumbleunlessyou'vemessedaroundwith$[butyoushouldn'tdothatmumble)
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.
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 1261
***************************************