[17089] in Perl-Users-Digest
Perl-Users Digest, Issue: 4501 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 3 00:06:33 2000
Date: Mon, 2 Oct 2000 21:05:11 -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: <970545910-v9-i4501@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 2 Oct 2000 Volume: 9 Number: 4501
Today's topics:
Re: [Q] Greedy matching across multiples lines. <uri@sysarch.com>
Re: [Q] Greedy matching across multiples lines. <mauldin@netstorm.net>
Another netiquette question? was Re: How to get length <flavell@mail.cern.ch>
Re: benefits of arrays over hashes(associative arrays) <bart.lateur@skynet.be>
Re: benefits of arrays over hashes(associative arrays) (Logan Shaw)
Re: benefits of arrays over hashes(associative arrays) (Logan Shaw)
Re: benefits of arrays over hashes(associative arrays) <uri@sysarch.com>
Re: Blank line appending data to file (Gwyn Judd)
converting \codes <Lloyd_Lim@mail.limunltd.com>
error in mapping array slice <r28629@email.sps.mot.com>
Re: error in mapping array slice <mauldin@netstorm.net>
Re: Levels of Perl Programmer (David W. Crawford)
Re: need help on a small cgi thank u <david.obrien@ssmb.com.au>
Re: Newbie can't handle the "true"th... explanation de (Craig Berry)
Re: Newbie can't handle the "true"th... explanation de <tina@streetmail.com>
Re: Perl on PWS on Win ME <david.obrien@ssmb.com.au>
perl tk canvas question bhaskaracharya@my-deja.com
Re: perl tk canvas question <simonis@myself.com>
Re: Please help me with this email parsing problem (Dave Sherohman)
Re: Proving the greatness of mod_perl <philipg@atl.mediaone.net>
Re: Regex comparing street addresses <peter.sundstrom@eds.com>
Regex: Perl5 to Perl4 Problem <01031149@3web.net>
Re: Reverse by paragraphs - NOT! <godzilla@stomp.stomp.tokyo>
Re: Reverse by paragraphs - NOT! <godzilla@stomp.stomp.tokyo>
Re: scripts not working <pdmos23@geocities.com>
Re: sort files <uri@sysarch.com>
Re: Strange behaviour with @{...} <mauldin@netstorm.net>
Re: substitution in multiple files? <tina@streetmail.com>
Re: substitution in multiple files? <anmcguire@ce.mediaone.net>
Re: Testing for non-numerics in a scalar (Keith Calvert Ivey)
Re: Testing for undef in XS (Brian Ingerson)
Win32::SerialPort Tutorial? <mc@backwoods.org>
XML::Simple and not well-formed error <thomas2@dalnet.se>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 03 Oct 2000 02:29:00 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: [Q] Greedy matching across multiples lines.
Message-Id: <x7g0me64k7.fsf@home.sysarch.com>
>>>>> "AP" == Anshuman Pandey <apandey@u.washington.edu> writes:
AP> {\mac apple banana orange pear guava kiwi grape{a} mango pear}
AP> {\mac apple banana orange pear guava kiwi grape{a} mango
AP> pear}
AP> while (<>) {
AP> s/{\\mac (.*)}/xyz()/gse;
AP> print;
AP> }
AP> sub xyz {
AP> $temp = $1;
AP> $temp =~ tr/aeiou/X/;
AP> "{\\mac $temp}";
AP> }
AP> {\mac XpplX bXnXnX XrXngX pXXr gXXvX kXwX grXpX{X} mXngX pXXr}
AP> {\mac XpplX bXnXnX XrXngX pXXr gXXvX kXwX grXpX{X} mango
AP> pear}
i tried the code with a list of those strings and it works fine for
me. your problem is that you don't have all of the second string in $_,
so the match stops at the close of grape{a} as it should.
when reading with <> you only get one line at a time so you have to
figure out that you need to read in the next line and append it to $_.
that can be done many ways but you have to specify how you detect short
lines so you can read the next one.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Tue, 03 Oct 2000 02:34:46 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: [Q] Greedy matching across multiples lines.
Message-Id: <39D94588.7094F351@netstorm.net>
Anshuman Pandey wrote:
> I would like to match text between two delimiters and process the match to
> my liking. The test program I have works, except for when the delimiter
> character occurs within the delimited text as a non-delimiter.
>
> Here is some sample text. The text delimiters are "{\mac" and "}",
> respectively:
>
> {\mac apple banana orange pear guava kiwi grape{a} mango pear}
>
> {\mac apple banana orange pear guava kiwi grape{a} mango
> pear}
>
> The program below is supposed to grab everying between "{\mac" and the
> right-most "}" and pass it to the subroutine xyz() for processing:
>
> while (<>) {
> s/{\\mac (.*)}/xyz()/gse;
> print;
> }
>
> sub xyz {
> $temp = $1;
> $temp =~ tr/aeiou/X/;
> "{\\mac $temp}";
> }
Above much more safely written by explicity passing $1 as an argument to
xyz():
s/{\\mac (.*)}/xyz($1)/gse;
sub xyz {
my $temp = shift;
...
> However, given the sample text, the program produces the following
> output:
>
> {\mac XpplX bXnXnX XrXngX pXXr gXXvX kXwX grXpX{X} mXngX pXXr}
>
> {\mac XpplX bXnXnX XrXngX pXXr gXXvX kXwX grXpX{X} mango
> pear}
>
What's probably happening is that
while (<>)
gets
{\mac apple banana orange pear guava kiwi grape{a} mango pear}
and processes it, then gets
{\mac XpplX bXnXnX XrXngX pXXr gXXvX kXwX grXpX{X} mango
and process it, then gets
pear}
and process it, giving you the output you get.
How you deal with this depends on how your data is structured, but
you'll have to concatenate pear) with the preceding line for it to
work. Here's my solution:
while (<>) {
if ( s/(?<!})\s*\n/ / && defined(my $nextline=<>) ) {
$nextline=~ s/^\s+//;
$_.= $nextline;
redo;
}
s/{\\mac (.*)}/xyz($1)/gse;
print;
}
-- Jim
------------------------------
Date: Tue, 3 Oct 2000 02:42:52 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Another netiquette question? was Re: How to get length of scalar?
Message-Id: <Pine.GHP.4.21.0010021956150.27436-100000@hpplus03.cern.ch>
On Mon, 2 Oct 2000, David Steuber wrote:
> I take it this group would prefer _not_ to have xposts?
This here is a comp group, and as such (IINM) it applies the general
rules of usenet netiquette. It shouldn't really be necessary to
renegotiate them every day.
The following represents my best understanding of this part of the
netiquette. In case of doubt, consult a suitable grandchild of
RFC1036.
It's a regular usenet custom that one should _not_ x-post across
closely-related groups, on the assumption that anyone who would be
_that_ interested would be subscribed to the most relevant one anyhow.
Especially one should not x-post to a *.misc and one or more of the
corresponding *.[specific] groups. Seems logical to me...
Where a topic is genuinely relevant to some otherwise quite unrelated
groups, that's the time when cross-posting (_properly-so-called_*)
would be appropriate.
In the minority of situations where crossposting is the choice,
then suggesting a narrower followup is nice (other things being equal)
[*]i.e not to be confused with multiposting, which I think I can
fairly say is widely agreed to be abhorrent, no?
But as the nice man said on "My Word":
"Sir, come, Stan says all to Caseys". :-)
------------------------------
Date: Tue, 03 Oct 2000 01:06:30 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <q8cits4e10beki4s4iqbm36313ebn56gvf@4ax.com>
Logan Shaw wrote:
>Oh boy, an opportunity to play devil's advocate. Here goes:
>
> @encode[map(ord, qw{ & < > })] = qw{ & < > };
> foreach (@lines)
> { s/([&<>])/$encode[ord($1)]/g; }
>
>It's about as concise and probably just about as fast.
Well OK. Now do the reverse function, mapping '&' into '&' etc.
--
Bart.
------------------------------
Date: 2 Oct 2000 20:54:00 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <8rbe7o$g93$1@provolone.cs.utexas.edu>
In article <slrn8tia3g.jr6.mgjv@martien.heliotrope.home>,
Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
>On 2 Oct 2000 17:52:54 -0500,
> Logan Shaw <logan@cs.utexas.edu> wrote:
>>
>> However, it takes more memory, more gymnastics, and more cheating.
>> (Cheating because if the indices to the array weren't guaranteed to be
>> between 0 and 255, I could end up using *lots* of memory, or I might
>
>$ perldoc perlunicode
I did, but it didn't say anything about anyone writing HTML in
Unicode.
Plus, I said I was cheating, didn't I?
- Logan
------------------------------
Date: 2 Oct 2000 21:23:56 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <8rbfvs$gc1$1@provolone.cs.utexas.edu>
In article <q8cits4e10beki4s4iqbm36313ebn56gvf@4ax.com>,
Bart Lateur <bart.lateur@skynet.be> wrote:
>Logan Shaw wrote:
>
>>Oh boy, an opportunity to play devil's advocate. Here goes:
>>
>> @encode[map(ord, qw{ & < > })] = qw{ & < > };
>> foreach (@lines)
>> { s/([&<>])/$encode[ord($1)]/g; }
>>
>>It's about as concise and probably just about as fast.
>
>Well OK. Now do the reverse function, mapping '&' into '&' etc.
O.K.:
@decode = ( [ 'amp', '&' ], [ 'lt', '<' ], [ 'gt', '>' ] );
foreach (@lines)
{
s/&(\w+)\;/(map ($_->[1], grep ($1 eq $_->[0], @decode)))[0]/ge;
}
Suddenly, it's less efficient, but not a ton since the list is short.
If it needs to be more efficient, I can re-write it pretty easily to do
a binary search instead of a linear search.
- Logan
------------------------------
Date: Tue, 03 Oct 2000 02:39:53 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <x7bsx2641x.fsf@home.sysarch.com>
>>>>> "LS" == Logan Shaw <logan@cs.utexas.edu> writes:
LS> Suddenly, it's less efficient, but not a ton since the list is
LS> short. If it needs to be more efficient, I can re-write it pretty
LS> easily to do a binary search instead of a linear search.
that is the whole purpose of a hash. to get close to O(1) lookup time on
average for string keys. the best other lookups run O( log N
). so saying it is slower than a hash is the reason we use hashes. and
hving it builtin makes it easier as you don't have to do the lookup algorithm
and string compares as perl does it for you.
and if you want another algorithm with the same syntax, use tie.
in perl6 it has been proposed (and probably will have) hashes with user
selected/loadable algorithms.
so stop this stupid thread. you can't optimize all data into one data
structure type. hence arrays and hashes are both needed for efficiency
reasons.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Tue, 03 Oct 2000 02:33:12 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Blank line appending data to file
Message-Id: <slrn8tihb7.f5o.tjla@thislove.dyndns.org>
I was shocked! How could Nige P <nige@npay.freeserve.co.uk>
say such a terrible thing:
>This is a multi-part message in MIME format.
Please don't do this. Long standing usenet tradition dictates that you
should post in plain-text only, thanks.
>Can anyone enlighten me please....?
>I am returning the contents of a file xxxx until a $ is detected.
>This data is then appended into another file yyyy.
>
>However each time this occurs I get a blank line between
>the data, but I cannot see why.....
>
>Many thanks for any input.
>
>$login->print("type xxxx");
> ($alertfile) =3D $login->waitfor('/\$ *$/');
>
> open (LIVEFILE,">>yyyy") ||
>die "Could not open file\n";
> print LIVEFILE "$alertfile";
Well it's really impossible to tell without knowing what $login is (I'm
guessing it's an object of some sort). Can you post a short snippet that
runs and exhibits the behaviour?
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Decorate your home. It gives the illusion that your life is more
interesting than it really is.
-C. Schulz
------------------------------
Date: 3 Oct 2000 01:57:35 GMT
From: Lloyd Lim <Lloyd_Lim@mail.limunltd.com>
Subject: converting \codes
Message-Id: <8rbeef$nss$1@samba.rahul.net>
I'd like to be able to process \t, \n, \r, ..., \033, \x1B, \c[
in a string and substitute the appropriate characters just like
Perl does. I'd also prefer avoiding eval, if possible.
I could easily do the tab, newline, etc. substitutions with
individual s/// statements, but I couldn't figure out a way
to do the octal, hex, and control substitutions without tons
of code.
I tried using the qq operator to do the interpolation but that
didn't work.
Any help would be appreciated.
Thanks,
+++
Lloyd Lim <Lloyd_Lim@mail.limunltd.com>
------------------------------
Date: Tue, 03 Oct 2000 09:18:48 +0800
From: Tk Soh <r28629@email.sps.mot.com>
Subject: error in mapping array slice
Message-Id: <39D933F8.65EB02C2@email.sps.mot.com>
Just run into something strange about array slice. Wonder if anyone can
point out where/what I am missing here.
try.pl:
-------
@a = 1..5; # line 1
@b = map {$_} @a[-10 .. -1]; # line 2
The error msg:
-------------
Modification of non-creatable array value attempted, subscript -10 at
try.pl line 2.
-TK
------------------------------
Date: Tue, 03 Oct 2000 02:51:00 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: error in mapping array slice
Message-Id: <39D94957.F2AF3C86@netstorm.net>
Tk Soh wrote:
>
> Just run into something strange about array slice. Wonder if anyone can
> point out where/what I am missing here.
>
> try.pl:
> -------
> @a = 1..5; # line 1
> @b = map {$_} @a[-10 .. -1]; # line 2
>
> The error msg:
> -------------
> Modification of non-creatable array value attempted, subscript -10 at
> try.pl line 2.
>
From "Programming Perl", Chapter 33: Diagnostic Messages
You tried to make an array value spring into existence,
and the subscript was probably negative, even counting
from the end of the array backward.
Fairly obvious, I should think.
-- Jim
------------------------------
Date: 02 Oct 2000 22:07:58 -0400
From: dc@panix.com (David W. Crawford)
Subject: Re: Levels of Perl Programmer
Message-Id: <xz33diead8h.fsf@panix6.panix.com>
there's also Jon Orwant's levels, based on quiz responses:
0-20: Perl Intern. Hit head with board, read FAQ, retake test. Beware
Aquarius.
21-40: Perl Dentist. Keep telling yourself that you would have scored
a lot higher if you'd used the online documentation, and really isn't
that a better way to gauge programming competence. Create dissent
between Scorpios and Libras.
41-60: Perl Orthopedist. Feel guilty for peeking at the answers,
disagreeing with them, and deciding that you're really correct. A
Taurus will cut you off on the freeway.
61-80: Perl Neurosurgeon. Your future holds satori and high consulting
fees. Expect a lawsuit from a Gemini.
81+: You already knew the answers because you attended the quiz show
in person. Shame on you for pretending that you really did this
well. If a Sagittarius offers to duel, refuse.
From http://corptpj.earthweb.com/quiz-show-98.html
David W. Crawford <dc@panix.com>
Perl psychiatrist, Los Gatos, CA
abigail@foad.org (Abigail) writes:
> ?? I am looking for an article (probably written by Tom Christiansen) on
> ?? the levels of a perl programmer.
>
> Try http://language.perl.com.
>
------------------------------
Date: Tue, 03 Oct 2000 12:47:12 +1000
From: Dave O'Brien <david.obrien@ssmb.com.au>
Subject: Re: need help on a small cgi thank u
Message-Id: <39D948B0.B5D6A13E@ssmb.com.au>
Mark wrote:
>
> In article <8r0chn$ojp$1@nnrp1.deja.com>,
> sendkeys@my-deja.com wrote:
> > hi all here is the cgi im using
> >
> > #!/usr/bin/perl
> <snip>
> > print "</ul></body></html>";
> >
> > just a basic upload file cgi it all works but my main problem is i
> > can't delete the files after i make them. when i try i get a
> Permission
> > denied. and when i try to set to files to 777 i get a "Permission
> > denied" so im guessing the script hasnt stopped running but i have no
> > way to tell.if the script is running is there some why of telling? its
> > on a unix server and i can use telnet. any help would be great thank
> > you very much.
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> >
> Quite probably the reason you are getting the Permission Denied error
> is because you do not own the file.
>
> When the script creates the file via the upload it is probably setting
> the owner to the user that Apache is running as. Probably "nobody",
> therefore, as part of your script, following the upload you will have
> to chmod the file to 775 or chown the file to yourself.
>
> You can check this simply by doing an ls -l on the command line, or
> even using ws_ftp and looking at the Dir Info.
>
> Just a thought...
>
> Mark
>
> --
> Please reply to this newsgroup as my Deja mail
> is used as a spam catcher only!
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Delete the files with the (a) CGI script, then it will be running as the
web server user.
------------------------------
Date: Tue, 03 Oct 2000 01:33:22 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Newbie can't handle the "true"th... explanation desired
Message-Id: <stidr2g7g32a5b@corp.supernews.com>
Brad Baxter (bmb@ginger.libs.uga.edu) wrote:
: OTOH, you could do this and just not care what the value actually is,
:
: my $true = 1==1;
: my $false = 1==0;
Or even
my $false; # undef by default, a false value
my $true = ! $false;
This has a certain pleasing austerity to it.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Quidquid latine dictum sit, altum viditur."
|
------------------------------
Date: 3 Oct 2000 03:34:01 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Newbie can't handle the "true"th... explanation desired
Message-Id: <8rbk39$h97f4$3@ID-24002.news.cis.dfn.de>
hi,
In comp.lang.perl.misc Ren Maddox <ren.maddox@tivoli.com> wrote:
> Larry Rosler <lr@hpl.hp.com> writes:
>> In article <m34s2vout4.fsf@dhcp11-177.support.tivoli.com> on 02 Oct 2000
>> 15:24:39 -0500, Ren Maddox <ren.maddox@tivoli.com> says...
>> > Larry Rosler <lr@hpl.hp.com> writes:
>> >
>> > > $name = undef; # The value of $name is now undefined.
>> > >
>> > > undef $name; # The variable $name no longer exists.
>>
>> > What then, is the difference?
>>
>> For other than a lexical variable, whether or not the name actually
>> exists in the symbol table. What the imnplications of this are (if any)
>> I don't know, because I have never had to muck around at that level of
>> coding.
> Actually, it doesn't even seem to do that:
> perl -e '$,=$\=$/;undef $x;print grep /^x$/, keys %::'
|=head2 How can I free an array or hash so my program shrinks?
|
|You can't. On most operating systems, memory allocated to a program
|can never be returned to the system. That's why long-running programs
|sometimes re-exec themselves. Some operating systems (notably,
|FreeBSD and Linux) allegedly reclaim large chunks of memory that is no
|longer used, but it doesn't appear to happen with Perl (yet). The Mac
|appears to be the only platform that will reliably (albeit, slowly)
|return memory to the OS.
|
|We've had reports that on Linux (Redhat 5.1) on Intel, C<undef
|$scalar> will return memory to the system, while on Solaris 2.6 it
|won't. In general, try it yourself and see.
|
|However, judicious use of my() on your variables will help make sure
|that they go out of scope so that Perl can free up their storage for
|use in other parts of your program. A global variable, of course, never
|goes out of scope, so you can't get its space automatically reclaimed,
|although undef()ing and/or delete()ing it will achieve the same effect.
|In general, memory allocation and de-allocation isn't something you can
|or should be worrying about much in Perl, but even this capability
|(preallocation of data types) is in the works.
undef $x; is a little bit quicker as
$x = undef;
undef $x is the correct use.
what happens is maybe that with "$x = undef"
a new undef value on the fly is produced
which is assigned to $x. that's just useless.
however, it makes a difference with arrays:
@a = undef; will not result in an empty array
as one might assume.
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \__,_\___/\___/_| /__/ perception
please don't email unless offtopic or followup is set. thanx
------------------------------
Date: Tue, 03 Oct 2000 12:44:36 +1000
From: Dave O'Brien <david.obrien@ssmb.com.au>
Subject: Re: Perl on PWS on Win ME
Message-Id: <39D94814.F3832142@ssmb.com.au>
Drew Simonis wrote:
>
> Jim Gaasedelen wrote:
> >
> > You can't seem to get it through your head, can you? Security is NOT
> > always a
> > problem for everyone. I know. It is NOT a problem for me!!!
>
> Ignorance like this is exactly why security _is_ a problem for
> everyone. Thanks for being part of the problem.
I think the point he is making is that he doesn't care about the
security of his machine, not that it has invincible security now. If he
doesn't care about security on his own machine, why should anyone else?
------------------------------
Date: Tue, 03 Oct 2000 01:05:46 GMT
From: bhaskaracharya@my-deja.com
Subject: perl tk canvas question
Message-Id: <8rbbd6$ltp$1@nnrp1.deja.com>
hi,
I am drawing boxes in a canvas and need to bind the names of boxes.
I want the names of boxes to show up only when user clicks or moves
across the boxes. i.e i want to do it later. So :
1. how can i bind the name to the box?
2. how can i draw it later as a bind?
thanks
note : pls post to my email if possible
Attempt:
for (
$drawCanvas->createRectangle( $llx,$lly,$urx,$ury);
##### i dont wabt to do below but seem to have no
##### other option to store name and print later
$drawCanvas->createText( $text_x, $text_y, -text => "boxname");
}
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 03 Oct 2000 02:24:30 GMT
From: Drew Simonis <simonis@myself.com>
Subject: Re: perl tk canvas question
Message-Id: <39D940CD.160DE6FB@myself.com>
bhaskaracharya@my-deja.com wrote:
>
> hi,
>
> I am drawing boxes in a canvas and need to bind the names of boxes.
Try comp.lang.perl.tk, we wouldn't want those folks to be
neglected, now would we?
------------------------------
Date: Tue, 03 Oct 2000 01:40:07 GMT
From: esper@news.visi.com (Dave Sherohman)
Subject: Re: Please help me with this email parsing problem
Message-Id: <slrn8tie7n.h8u.esper@pchan.dojo>
On 2 Oct 2000 17:43:05 -0500, Ranyart Olias <ranyart@cyberspace.org> wrote:
> I am trying to find a small snippet of code that can parse a text
> file, (which happens to be a mail message body), and can extract the
> plain text out (and discard any attachments, html, etc.).
Go to freshmeat and find yourself a copy of stripmime.
--
"Two words: Windows survives." - Craig Mundie, Microsoft senior strategist
"So does syphillis. Good thing we have penicillin." - Matthew Alton
Geek Code 3.1: GCS d- s+: a- C++ UL++$ P+>+++ L+++>++++ E- W--(++) N+ o+
!K w---$ O M- V? PS+ PE Y+ PGP t 5++ X+ R++ tv b+ DI++++ D G e* h+ r++ y+
------------------------------
Date: Tue, 03 Oct 2000 04:04:11 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: Proving the greatness of mod_perl
Message-Id: <%UcC5.10718$jJ4.2830247@typhoon.southeast.rr.com>
<cmalcolm@my-deja.com> wrote in message news:8rar0b$7nm$1@nnrp1.deja.com...
> Is there a list of major web sites that are using mod_perl
> succesfully? I am trying to persuade some investors that we are great,
> because we want to use mod_perl to build a site that will potentially
> be very large.
>
> The people assessing us seem to think that Perl is no good for these
> reasons:
>
> 1) It is good for prototyping, but is bad for a site that must be
> highly scalable.
Scalability is a function of the software architecture. It has very little
to do with the language used to implement that architecture. Perl can be
used to create highly scalable software systems, e.g. IMDB.
> 2) It is too slow.
mod_perl is _potentially_ slower than code written in a lower-level
language, but it's easier (IMHO) to write good, clean code in Perl than in
C++. Also, development time is expensive. The money spent on development
of C++ or Java versus Perl would generally pay for much more hardware than
would be needed to offset the speed difference.
> 3) It is not object-oriented (They listen for words like "Java"
> and "C++" to decide if something is object-oriented).
Well, they're just plain wrong here. The CPAN holds multitudes of object
oriented modules. You would be hard-pressed to come up with a recurring
programming problem for which there isn't a solution for on CPAN.
> 4) They have not heard of mod_perl before.
Are they living under a rock?
> 5) They say you can't employ 'Perl certified engineers'!!!
There is at least one "authority", www.brainbench.com, that tests for Perl
knowledge.
> So, I have a choice:
>
> A) Abandon Perl with mod_perl and start using Java
> B) Try and educate these guys.
>
> The thing is, it seems to me that if you are trying to pursuade someone
> to invest in your idea, they will employ consultants to assess you, and
> these consultants only know about commercial, proprietry stuff, such as
> Java, Oracle, OAS, etc.
>
> How can I educate these people? It is absolutely infurating that
> companies such as Oracle can get their software in use, just by
> brainwashing people in important places that it is the only way
> forward. Whilst Oracle _is_ good, it is not what we need.
One thing you might point out is that Oracle databases and applications are
obscenely expensive. Have a look at
http://oraclestore.oracle.com/cec/cstage?eccookie=&template=help_licensing.e
n.htm.
> We firmly believe, in fact we KNOW, that mod_perl makes perl the best
> choice for our application. We know that these consultants are just
> plain ignorant.
>
> What can be done to persuade people that mod_perl is a viable
> solution? I don't want to be forced to change our whole development
> plan just to satisfy some consultants who are not up to date on these
> things!
As much as I hate to be pessimistic, there's probably not much more that can
be done. Most big business people will insist on going with a commercial
solution (even if they know of something better), just because they have to
have someone they can sue if things go kablooie. Sad but true. As Linux
gains commercial acceptance, there will be more people open to the idea of
using software for which they didn't have to pay truckloads of cash.
p
------------------------------
Date: Tue, 3 Oct 2000 14:33:29 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: Regex comparing street addresses
Message-Id: <8rbd8v$a2h$1@hermes.nz.eds.com>
Jim Mauldin wrote in message <39D92AD1.77F7257F@netstorm.net>...
>Peter Sundstrom wrote:
>>
>[snip]
>>
>> Perhaps I didn't spell it out as precisely as I should have. The
>> identifiers *must* have a space before and after them (therefore wouldn't
>> match at the beginning or end of line).
>
>Useless to belabor the point, I suppose, but if the above is true, then
> Compare('4 123A SMITH ST','123A 4 SMITH ST');
>
>would return DIFFERENT (no space before initial 4), whereas in your
>original post you say it should return SAME.
My mistake :-(
My spec was correct (incidently, this is part of a conversion of a MVS
assembler program. Guess which one is the shorter version), the sample data
and regex should have all had a space before the number.
------------------------------
Date: Mon, 2 Oct 2000 21:02:26 -0600
From: "Duke Normandin" <01031149@3web.net>
Subject: Regex: Perl5 to Perl4 Problem
Message-Id: <bYbC5.3216$Jd4.24411@jekyl.ab.tac.net>
Don't ask -- Perl5 to Perl4 ?????
I'm a newbie to Perl & regex.
I need to get the following Perl5 code working in Perl4:
$email =~s/^.*?(From|Received|Sender|Return-Path|Date):/$:/s;
Would someone please interpret what's going on in the above
code so that I can learn something; and show me what changes
are needed to get it working with Perl4? The code is from
some utility I DL'ed off the 'net.
--
tia....duke
------------------------------
Date: Mon, 02 Oct 2000 20:42:48 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Reverse by paragraphs - NOT!
Message-Id: <39D955B8.8FC3E766@stomp.stomp.tokyo>
ollie_spencer@my-deja.com wrote:
(snippage)
> I didn't mean to imply I don't have a way to reverse
> the file paragraph by paragraph - I just reverse the
> whole dern thing...
There was never any doubt in my mind you would
change your parameters and argue with each person
who responded to your article.
Each person who responds, invests time and effort
into writing an article, into helping people. Each
person who responds, gives a bit of her or his life,
to another, with good intent.
Having you here, constantly changing parameters,
arguing with people, looking to get in a dig when
you can, posting malice intent articles under myriad
fake names, both male and female, is extremely rude,
extremely thoughtless and your track history, clearly
defines you as mentally unstable if not outright,
psychotic.
In time, all will begin to recognize you for who
you are and, what you are; worst troll to ever
ruin this group.
Annoy me again, I'll pull another of my sleeve aces.
Kira
------------------------------
Date: Mon, 02 Oct 2000 20:54:28 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Reverse by paragraphs - NOT!
Message-Id: <39D95874.42A1936C@stomp.stomp.tokyo>
Jeff Pinyan wrote:
> Godzilla! wrote:
> > There are two undocumented functions in Perl...
> > use slurp (schizoid);
> > use while (schizoid);
> [bzzt] What functions are you talking about? 'while' is a loop
> constructor, not a function. And 'slurping' is a name for reading all of
> input at once. Check the definition of 'function' -- you're not quite
> right here....
I understand your confusion. Many beginners, many new
to Perl, like yourself, are unaware of many undocumented
features of Perl. In time, if you study, if you learn and
work real hard at this, years from now, you will reach
my level of Perl expertise, least currently. Who knows,
a day might come, you will actually match my Perl knowledge.
Your chances are good at catching up with me. At my age,
I am beginning to forget more than I remember. You will
probably catch up with me as a result of my forgetting
half of what I know today.
Godzilla!
--
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class
------------------------------
Date: Tue, 03 Oct 2000 03:41:20 GMT
From: Pasquale <pdmos23@geocities.com>
Subject: Re: scripts not working
Message-Id: <39D95606.B3E2EC72@geocities.com>
Thanks. I received the following error:
Can't locate CGI/Cookie.pm in @INC.....
Does this mean they(F2S) do not have or support CGI::Cookie?
Jeff Zucker wrote:
> Pasquale wrote:
> >
> > I have some perl scripts I was testing on Hypermart and they were
> > working perfectly fine. I tried them on Freedom 2 Surf & they are not
> > working(Internal Server Error).
> > I have checked the shebang line and all the other paths. I am using "-T"
> > & "-w" on the shebang line. I am also using "strict", "CGI" &
> > "CGI::Cookie." Any reasons why?
>
> All excellent, but none relevant to this problem :-). The one you need
> is
>
> use CGI::Carp qw(fatalsToBrowser);
>
> Because that is the only one that can tell you (maybe) what error you
> are getting. Or even better, run it from the command line to make sure
> it is working there first.
>
> --
> Jeff
------------------------------
Date: Tue, 03 Oct 2000 02:16:49 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: sort files
Message-Id: <x7itra654d.fsf@home.sysarch.com>
>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
LR> In article <MPG.1442b7d79d03946f98adf4@nntp.hpl.hp.com> on Mon, 2 Oct
LR> 2000 16:19:24 -0700, Larry Rosler <lr@hpl.hp.com> says...
LR> ...
>> I'm sure Uri would be happy to massage the text (currently available in
>> PDF, or in crummy HTML, or in the Micro$..t Word format from which the
>> HTML was generated) into POD.
LR> It would also give him a chance to remove the discussion of the still
LR> not completed Sort::Records module that was promised in the paper
LR> (<blush>).
both to be done when my supply of tuits gets refilled. or when
moronzilla finally leaves here.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Tue, 03 Oct 2000 01:22:34 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: Strange behaviour with @{...}
Message-Id: <39D9349D.3CC4C003@netstorm.net>
Martien Verbruggen wrote:
>
> On Mon, 02 Oct 2000 13:27:36 GMT,
> Jim Mauldin <mauldin@netstorm.net> wrote:
> >
> > This behavior is expected, not strange. The construct @{$a} (which
> > could be stated as @$a in this context) is not an operator. It is an
> > anonymous array whose referenece is contained in $a. Merely using @{$a}
> > in a statement causes the reference to spring into existence, even if
> > the array is empty (Perl tries to be helpful).
>
> Are you sure about that?
>
> $ perl -wl
> my $a;
> my @foo = @{$a};
> print $a;
> __END__
> Use of uninitialized value in array dereference at - line 2.
> Use of uninitialized value in print at - line 3.
>
> $
>
> The autovivification only happens in certain cases. Not merely on the
> use of a variable in a context where it _may_ contain an array
> reference. It's probably only in spots where it must contain one. Which
> spots they are is harder to identify easily.
You are correct in saying that I was a little too flip.
Autovivification canonically occurs in an lvalue context, though also in
other cases.
Upon further study, I found in "Programming Perl" 3rd edition under a
discussion of the exists function that a reference will be autovivified
"anywhere the arrow operator is used (explicitly or implicitly)".
Presumably, the statement
for (@{$a})
attempts to alias an implicit $a->[0] the first time through, whence the
reference.
> I'd hardly call it intuitive or even expected. I'd expect it with push
> and unshift, but not really with for.
Well, "expected" in the sense that from time immemorial, perl has
supplied us with what we seem to want, even if what we want is weird.
Which is why -w is so important.
-- Jim
------------------------------
Date: 3 Oct 2000 01:19:19 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: substitution in multiple files?
Message-Id: <8rbc6m$h97f4$2@ID-24002.news.cis.dfn.de>
hi,
In comp.lang.perl.misc Valerie Dodson <valerie.dodson@searhc.org> wrote:
> I have multiple perl scripts that contain $name!@emailaddress within,
> and I would like to replace @emailaddressdomain with
> @newemailaddressdomain. Can someone please help me figure out how to do
> this without having to edit each individual file seperately? Any help
> is very much appreciated!
> p.s. I tried this and it didn't seem to work:
> perl -pi.bak -e `s/emailaddressdomain/newemailaddressdomain/g`
try quotes ' instead of backticks `
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \__,_\___/\___/_| /__/ perception
please don't email unless offtopic or followup is set. thanx
------------------------------
Date: Mon, 2 Oct 2000 21:05:33 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: substitution in multiple files?
Message-Id: <Pine.LNX.4.21.0010022103570.3038-100000@hawk.ce.mediaone.net>
On Mon, 2 Oct 2000, Valerie Dodson quoth:
VD> I have multiple perl scripts that contain $name!@emailaddress within,
VD> and I would like to replace @emailaddressdomain with
VD> @newemailaddressdomain. Can someone please help me figure out how to do
VD> this without having to edit each individual file seperately? Any help
VD> is very much appreciated!
VD>
VD> p.s. I tried this and it didn't seem to work:
VD>
VD> perl -pi.bak -e `s/emailaddressdomain/newemailaddressdomain/g`
perl -pi.bak -e 's/emailaddressdomain/newemailaddressdomain/g' *
^^^
Works just fine for me. Did you forget the '*'?
anm
--
perl -wMstrict -MText::ParseWords -e "
system echo => grep defined() ? /./ : q++ => quotewords '\s+', 0, <<JAPH;
"""""""""""""""""""""""""""""""" Just """"""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" another """"""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" Perl """"""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" Hacker """"""""""""""""""""""""""""""""
JAPH
"
------------------------------
Date: Tue, 03 Oct 2000 00:07:35 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Testing for non-numerics in a scalar
Message-Id: <39d92252.600169@news.newsguy.com>
steve@nospam.co.uk (Steve) wrote:
>I am trying to identify non-numerics in an integer.
>
>Could anyone comment on why this doesn't work?
Because it bears only a vague resemblance to the correct syntax?
>$numbercheck= 1234ty56;
>
>if ($m = ~m"(\d/$numbercheck/)")
>{
>print "non-numerics found\n";
>}
There are so many things wrong it's pointless to try to fix
them. Read the documentation (particularly perlop and perlre),
and try to understand this:
print 'non-numerics found' if $numbercheck =~ /\D/;
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: 3 Oct 2000 06:00:26 +0200
From: brian@ingerson.com (Brian Ingerson)
Subject: Re: Testing for undef in XS
Message-Id: <39D95A08.B6B02755@ingerson.com>
> I'd like to test an SV * parameter in my XSUB for undefinedness.
>
> I can't find this documented in perlguts or perlxs, and sv.h doesn't
> make it clearer either.
From 'perldoc perlapi' (available in 5.6.0)
PL_sv_undef
This is the `undef' SV. Always refer to this as
`&PL_sv_undef'.
SV PL_sv_undef
>
> I've found example code[1] that compares the SV *arg against
> &PL_sv_undef, but that seems wrong (I tried it anyway, and my testing
> confirms it.)
What is your testing?
Scanning the Perl 5.6 source revealed 164 lines containing PL_sv_undef
most of which are setting to or testing for undef. I've used PL_sv_undef
successfully in my code as well. I'm suspect of your method.
Brian Ingerson
INGY@cpan.org
perl -le 'print jaxh("Perl");use Inline C=>q|SV*jaxh(char*x){return
newSVpvf("Just Another %s Hacker",x);}|'
--
Posted from w3.zipcon.net [205.199.135.9]
via Mailgate.ORG Server - http://www.Mailgate.ORG
------------------------------
Date: Mon, 02 Oct 2000 21:45:46 -0400
From: MC <mc@backwoods.org>
Subject: Win32::SerialPort Tutorial?
Message-Id: <39D93A49.4B6AD052@backwoods.org>
Can anyone point me to a tutorial or reference on the Win32::SerialPort module
other than the POD material. The POD material just ~barely~ covers the bones of
it and is rather less than clear as to the usage of many of the functions. I've
managed, ~finally~, to make a basic script work, but thats as far as I can go
w/o better documentation.
MC
--
---------------------------------------------------------------------
I haven't lost my mind!!! It's backed up on disk.
"The world wont end with a bang, or even a whimper, but with an error
message." -- format C:
------------------------------
Date: Tue, 03 Oct 2000 02:09:07 GMT
From: "Thomas Åhlen" <thomas2@dalnet.se>
Subject: XML::Simple and not well-formed error
Message-Id: <7dbC5.53$YF6.111752@news.bahnhof.se>
Hi i have generated an XML file with a perl script and a template package.
When i try to parse the XML file i get an error but i can't see what is
wrong.
Can someone please help me.
i get the following error parsing my XML file
not well-formed at line 33657, column 71, byte 3044169:
<Planet id="10" alliance="U.V.T/ARK" name="Crudeism" ruler="Wiseguy"
size="325" score="637036"/>
<Planet id="11" alliance="UVT/C46" name="G-spot" ruler="Orgazmo"
size="203" score="955981"/>
<Planet id="12" alliance="U.V.T/C46" name="Obereschingen" ruler="Mr.
Dummbatz" size="214" score="793690"/>
=====================================================^
<Planet id="13" alliance=" " name="Classic Planet" ruler="Classic
Killer" size="1" score="14324"/>
<Planet id="14" alliance=" " name="Default" ruler="Default" size="6"
score="49344"/>
<Planet id="15" alliance="ARK/FED" name="Water Planet" ruler="Ocaen
Man" size="90" score="648989"/>
at /usr/lib/perl5/site_perl/5.005/i386-linux/XML/Parser.pm line 185
well under my shell it points to the " in ="Mr
This code is used for the parsing:
-----------------
use strict;
use XML::Simple;
my $universe = XMLin('pa_universe.xml', keyattr => { Cluster => "id", Galaxy
=> "id", Planet => "id" }, parseropts => [ ErrorContext => 3 ] );
------------------
Here you can get the XML file (size 1.3Mbytes):
http://planetarion.obidobi.com/export/pa_universe_xml.gz
For you who are qurious.
I am writing a perl statistics interface for a online game called
Planetarion. http://www.planetarion.com
Thanks for any help.
Thomas Åhlen
------------------------------
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 4501
**************************************