[22124] in Perl-Users-Digest
Perl-Users Digest, Issue: 4346 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 5 18:05:34 2003
Date: Sun, 5 Jan 2003 15:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 5 Jan 2003 Volume: 10 Number: 4346
Today's topics:
Re: Can't use string as an ARRAY ref while "strict refs (Ricardo)
Re: changing user password <me@privacy.net>
Re: changing user password (Tad McClellan)
Re: changing user password <tmartin15@jam.rr.com>
Re: Inserting text top of plain/text MIME section <me@privacy.net>
Re: Please help - CYGWIN install of Apache+Perl <nobody@home.net>
Re: Please help - CYGWIN install of Apache+Perl <samik_nospam@freeshell.org>
Re: Problem with huge dataset, 100000000 a magic number <mgjv@tradingpost.com.au>
regex code evaluation (??{code}) (weberh)
Re: regex code evaluation (??{code}) (Tad McClellan)
Re: Should I worry about the optimizer. ctcgag@hotmail.com
Re: Should I worry about the optimizer. <bart.lateur@pandora.be>
Re: Threads, dynamic loading programs, and using global (Joe)
Re: top-posting (was Re: regexp question) (Tad McClellan)
Trying to capture blocks of data <vispy1@attbi.com>
Re: What are the software editor/creative choices for P <jbarrington@comcast.non>
Re: What are the software editor/creative choices for P <jbarrington@comcast.non>
Re: While loop <No_Mail_Address@cox.net>
Re: While loop (Tad McClellan)
Re: While loop (h\)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Jan 2003 13:11:39 -0800
From: dpw@clara.co.uk (Ricardo)
Subject: Re: Can't use string as an ARRAY ref while "strict refs" in use (again)
Message-Id: <2911a09c.0301051311.30c6f1ee@posting.google.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<av99ce$95h$1@mamenchi.zrz.TU-Berlin.DE>...
> The basics of all this can be found in perlref, and lots of applications
> and examples are in perldsc. You should put both on your reading list.
>
> Anno
Anno,
Thanks, I found these docs in my IndigoPerl html/lib/pod directory. They
are a bit beyond me at present, and have given me a bit of brain-ache, but I
will persist with them as they most certainly contain information I need to
understand. In fact I was already using references to hashes and arrays in
my DBI calls to MySQL databases, but without fully understanding them.
Thanks for the pointers.
------------------------------
Date: Mon, 6 Jan 2003 08:15:25 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: changing user password
Message-Id: <ava79e$d0a9a$1@ID-172104.news.dfncis.de>
"Tommy" <tmartin15@jam.rr.com> wrote in message
news:sCZR9.111109$6H6.3691234@twister.austin.rr.com...
> Is there a way to change the users password via perl? I need to create an
> html page that will allow the user to modify this if possible.
And which password might you be refering to? Login password, .htaccess
password, FTP password, Samba password, Database password, custom
application password.........?
------------------------------
Date: Sun, 5 Jan 2003 15:09:38 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: changing user password
Message-Id: <slrnb1h7oi.9is.tadmc@magna.augustmail.com>
Tommy <tmartin15@jam.rr.com> wrote:
> Is there a way to change the users password via perl?
perldoc -q password
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 05 Jan 2003 22:39:27 GMT
From: "Tommy" <tmartin15@jam.rr.com>
Subject: Re: changing user password
Message-Id: <zu2S9.112688$6H6.3749006@twister.austin.rr.com>
The login user account password.
Tommy
"Tintin" <me@privacy.net> wrote in message
news:ava79e$d0a9a$1@ID-172104.news.dfncis.de...
>
> "Tommy" <tmartin15@jam.rr.com> wrote in message
> news:sCZR9.111109$6H6.3691234@twister.austin.rr.com...
> > Is there a way to change the users password via perl? I need to create
an
> > html page that will allow the user to modify this if possible.
>
> And which password might you be refering to? Login password, .htaccess
> password, FTP password, Samba password, Database password, custom
> application password.........?
>
>
------------------------------
Date: Mon, 6 Jan 2003 08:16:48 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: Inserting text top of plain/text MIME section
Message-Id: <ava7c1$dnags$1@ID-172104.news.dfncis.de>
"Steve C" <sjcole@nospam.hotmail.com> wrote in message
news:1041767591.506583@ananke.eclipse.net.uk...
> Hi Folks,
> Sorry - a newbie question..
>
> I'm looking to insert a line of text in the 'top' of an e-mail message
body.
> The problem is that some 'users' have HTML e-mail format enabled by
default
> (Outlook clients mainly)
> also the plain/text section is not always the first MIME part encountered
> within the e-mail. Also the text can't necessarily go immediately after
the
> plain/text Content-Type: header as sometimes you get an entry like
> charset="iso-8859-1"
> on the following line, or should I use 'paragraph mode' to get round this?
>
> The mail message arrives on STDIN and needs to be passed back to STDOUT,
> with a one line text hacked into the top of the plain/text part bodypart.
>
> What would be the simplest way of going about this?
>
> Any help or pointers in the right direction would be appreciated.
I'd use MIME::Lite and use multipart/alternative
------------------------------
Date: Sun, 05 Jan 2003 19:37:35 GMT
From: "Al" <nobody@home.net>
Subject: Re: Please help - CYGWIN install of Apache+Perl
Message-Id: <3Q%R9.573$g54.43671705@newssvr13.news.prodigy.com>
"Boris Pelakh" <pelakh@yahoo.com> wrote in message
news:44ec9ada.0301050959.aaa1537@posting.google.com...
> I installed perl 5.6 and apache 1.3 from the cygwin setup program, but
> it did not install mod_perl. I cannot find mod_perl.so anywhere. I also
> cannot find there httpd.conf was put or even how to start apache. All the
> other modules were installed in cygwin/lib/apache. I have previously done
the
> IndigoPerl installation and it was very straight forward.
>
> I appreciate any help I can get.
>
> -- Boris
There is no mod_perl for Apache under Cygwin available under the Cygwin
installer. There used to be a 3rd. party "hack" of mod_perl for this
configuration that one could try to install manually but it's been a long
time since I last looked into it and I don't remember where I saw it. You
could try searching on the cygwin site or the Apache site or maybe even
google. As to where the httpd.conf file is located, on my install, it is
under "cygwin/etc/apache"
Al
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.435 / Virus Database: 244 - Release Date: 12/30/02
------------------------------
Date: Sun, 05 Jan 2003 15:18:12 -0600
From: Samik Raychaudhuri <samik_nospam@freeshell.org>
Subject: Re: Please help - CYGWIN install of Apache+Perl
Message-Id: <ava76h$kis$1@news.doit.wisc.edu>
I don't think you need mod_perl in order to run perl cgi programs in
Cygwin apache. In fact, my perl cgi programs run just fine w/ the
default installation of perl and apache in Cygwin (Win XP). If you are
not able to run cgi progs which come apache installation, may be u
reinstall afresh.
-Samik
On 1/5/2003 11:59 AM, Boris Pelakh wrote:
> I installed perl 5.6 and apache 1.3 from the cygwin setup program, but
> it did not install mod_perl. I cannot find mod_perl.so anywhere. I also
> cannot find there httpd.conf was put or even how to start apache. All the
> other modules were installed in cygwin/lib/apache. I have previously done the
> IndigoPerl installation and it was very straight forward.
>
> I appreciate any help I can get.
>
> -- Boris
--
Samik Raychaudhuri
University of Wisconsin, Madison
http://samik.freeshell.org/
------------------------------
Date: Sun, 05 Jan 2003 22:01:35 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Problem with huge dataset, 100000000 a magic number?
Message-Id: <slrnb1hb06.307.mgjv@verbruggen.comdyn.com.au>
On Fri, 03 Jan 2003 19:02:59 GMT,
Mike Hunter <mthunter@students.uiuc.edu> wrote:
> Greetings all,
>
> I'm using perl to crunch some data generated from flow-tools. My script
> works well until I get into really large data, where I end up with
> problems. I may very well be running the machine out of memory, but
> some recent debugging output produced this:
>
> processing line 99900000
> processing line 99950000
> processing line 100000000
Could it be that somewhere around line 100000000 you pass the 2 GB
mark [1]? Is the file larger than 2 GB, and if so, does your Perl on your
OS support that?
Martien
[1] That would only require 21 to 22 bytes per line.
--
|
Martien Verbruggen | I took an IQ test and the results were
Trading Post Australia | negative.
|
------------------------------
Date: 5 Jan 2003 11:57:19 -0800
From: weberh@zedat.fu-berlin.de (weberh)
Subject: regex code evaluation (??{code})
Message-Id: <7003ec4a.0301051157.407c50f7@posting.google.com>
Hi !
I'd like to know more about the
"highly experimental" code evaluation
--(??{code})-- feature in perl 5.6 regex'.
Couldn't find many postings on this topic.
perl -ne 'while(/([A|B|C|D]{6}).+?(??{reverse \1})/){print "$&\n"}'
foo
(find palindromedar :) ) returns
Unmatched ) before HERE mark in regex m/) << HERE cdd11101x0(RALACS/
at -e line 1, <> line 1.
Did I overlook something ?
Regards , Harald
------------------------------
Date: Sun, 5 Jan 2003 15:08:17 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: regex code evaluation (??{code})
Message-Id: <slrnb1h7m1.9is.tadmc@magna.augustmail.com>
weberh <weberh@zedat.fu-berlin.de> wrote:
> perl -ne 'while(/([A|B|C|D]{6}).+?(??{reverse \1})/){print "$&\n"}'
^^^^^^^^^^^^
That part is equivalent to:
[ABCD|]{6}
"|" is not "meta" in character classes.
I expect you wanted just:
[ABCD]{6}
(but that has nothing to do with the problem you're asking about)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 05 Jan 2003 19:14:16 GMT
From: ctcgag@hotmail.com
Subject: Re: Should I worry about the optimizer.
Message-Id: <20030105141416.504$HV@newsreader.com>
"Kasp" <kasp@NO_SPAMepatra.com> wrote:
> Hello Teh,
>
> AFAIK, Perl is a means to get your work done quickly (and dirtily).
>
> If you really want do some optimization, it would be better if you tried
> the same work in C/C++.
So it's better to spend 200 hours rewriting into C than 2 hours optimizing
your Perl?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: Sun, 05 Jan 2003 20:53:01 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Should I worry about the optimizer.
Message-Id: <7f6h1vg8nhpo6l8ee712obb887av6t71rg@4ax.com>
Teh (tî'pô) wrote:
>Hi, I'm benchmarking a few things and I'm not sure how much I should
>be worried about the optimizer optimizing away stuff.
And right fully so. Perl does optimise away some common code snippets,
so the benchmarks don't actually bench what you think they do. For
example
@ sorted = sort @unsorted;
@ sorted = sort { $a <=> $b } @unsorted;
From code inspection alone, you'd expect the latter to run much slower
than the former. However, they turn out to be quite comparable in speed.
It had me fooled once, because I expected to have found a way to measure
the callback overhead. But a common idiom, like this sort block, is
recognised and reimplemented internally without a callback. In other
words:
@ sorted = sort @unsorted;
@ sorted = sort { $a cmp $b } @unsorted;
compile to the same thing.
If you're benchmarking stuff, this something to be wary of.
--
Bart.
------------------------------
Date: 5 Jan 2003 13:03:09 -0800
From: joemercury@gmx.net (Joe)
Subject: Re: Threads, dynamic loading programs, and using globals?
Message-Id: <d6c57a14.0301051303.5a51ff09@posting.google.com>
Thanks Benjamin.
First comments, then new twist at the end.
I found out that I was foolish to include the 'package' statement in
the main file, this complicated package variables for me. And also
foolishly I lost the 'threads::shared' statement, but the " : shared"
and lock() didn't complain, hmmmmmmm :(
Once these 2 mistakes were fixed, things started to improve.
Benjamin Goldberg <goldbb2@earthlink.net> wrote in message >
> If it is to be placed in the main file, then it must be a package
> variable, not a lexical variable. Declare it with our() instead of
> my().
Works. I declared 'our $q : shared;' in main, and used $::q in the
loaded program with no other declarations.
> > 2) How do I place this resource just in the loaded file (preferred)?
>
> A variable which is to be shared between multiple threads *must* be
> declared as such *before* those threads get created.
>
Works. The only change in 'Main' is to move the 'require' from the
'start_thread' subroutine to before the 'create->thread'. The plugin
only needs 'our $q : shared;'. But see the new issue below :(.
> > 3) If this model can be improved, please advise.
>
> Whether it can be improved or not depends on how many different plugins
> there are to be loaded, and how many *will* be loaded in the lifetime of
> the process
I will have a look at this approach later.
A new twist:
Again, my program works as described, just that I am looking for
convienient way to share resources among same type of the plugins.
There is a little chicken and egg dilema here. In my real application
the Main program gets the name of the "plugin" to load from a socket.
So I am already in a thread after the 'accept', and after some more
processing, when I learn the name of the program to load and run.
That's why I was using the 'require' in the thread, not in Main.
while( 1 ) {
my $client = $daemon->accept;
my $thr = threads->create(\&start_thread, $client );
$thr->detach();
}
I do know what plugins are available. I can use a prepared list in
text file or dynamically scan all .pm in the home directory, so I can
pre 'require' them all in Main before starting the HTTP daemon. But I
wanted to do it on-the-fly if possible. I also didn't want to clone
all plugins in the new threads when I will use only one in the thread.
A side effect is that I can modify the plugin and it changes for the
next invocation.
JM.
------------------------------
Date: Sun, 5 Jan 2003 15:19:56 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: top-posting (was Re: regexp question)
Message-Id: <slrnb1h8bs.9k6.tadmc@magna.augustmail.com>
Kasp <kasp@NO_SPAMepatra.com> wrote:
> Tad and everyone at comp.lang.perl.misc.,
>
> My news reading client (mailgate.org) often givesme trouble. Sometimes, it
> will not allow me to reply to questions through bottom-posting
When you get the problem fixed, please change your address,
or send me email that you've gotten it fixed so I can take
your address back out.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 05 Jan 2003 22:29:26 GMT
From: "Vispy" <vispy1@attbi.com>
Subject: Trying to capture blocks of data
Message-Id: <9l2S9.455928$GR5.161470@rwcrnsc51.ops.asp.att.net>
Hello,
I am trying to split a scalar array into various variables and am not having
much luck. I have looked thru some books I have bought for some examples of
capturing chunks of info from a line to no avail.
Examples of the arrays is:
A01 Matrix-4 target532 - down -44.43 VDC
A02 Matrix-6 - up +209.9 AMPS
So the first block is start of the line & 4 characters, the second block is
6 thru 35 characters, the third block is 37 thru 42 characters and the
fourth block is 44 thru 47 characters. The blocks are separated by a space
character, but the blocks themselves can contain any characters including
spaces.
Can anyone help?
Thanks!!
Vispy
------------------------------
Date: Sun, 5 Jan 2003 15:25:48 -0500
From: "John B." <jbarrington@comcast.non>
Subject: Re: What are the software editor/creative choices for Perl
Message-Id: <saednYax2t5QCYWjXTWcpw@comcast.com>
Thanks for the information, Jürgen.
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:cIZR9.1645$Db.773@nwrddc02.gnilink.net...
> John B. wrote:
> > I'm a new webmaster for a smaller site that wants to investigate
> > possible uses for Perl (or CGI ?). I have some background in most
> > computer languages, but no experience with Perl and it's code within
> > an internet site.
>
> Please note that Perl != CGI. The two have nothing to do with each other
> except that Perl scripts are often used to implement CGI programs. You
> should not confuse them and keep the domains well separated. In particular
> asking a CGI question in a Perl NG is heavily frowned upon und will get
you
> on the fast way into many kill files.
>
> Beside that, please have a look at CPAN (www.cpan.org) and the Perl FAQ.
> It contains even an entry for editors:
> E:\MSN9M1-main>perldoc -q editor
> Found in E:\msn9m1-main\public\ext\perl\x86\lib\pod\perlfaq3.pod
> Is there an IDE or Windows Perl Editor?
> [Extensive commented list of over 20 editors removed]
>
> Although the FAQ is targeted towards Windows users, most of it applies to
> Unix, too.
>
> jue
>
>
------------------------------
Date: Sun, 5 Jan 2003 16:02:26 -0500
From: "John B." <jbarrington@comcast.non>
Subject: Re: What are the software editor/creative choices for Perl
Message-Id: <eoKdnS-I0-D6AIWjXTWcqQ@comcast.com>
Kasp.
Thanks for the book and editor information on Perl.
Also, my appologies on the minor reference towards CGI. I was under the
general impression that CGI was either a product of, a by-product of, or a
product that could work in conjunction with Perl, and this was due to a few
references that I had seen within a couple of web sites.
As I mentioned in my earlier message, I'm very new to the area of Perl and
it's particulars, and I wanted to investigate it to see how useful it would
be within the site. I can't wait to receive my books.
Best Regards,
John
"Kasp" <kasp@NO_SPAMepatra.com> wrote in message
news:av9pm4$qc5$1@newsreader.mailgate.org...
> "John B." <jbarrington@comcast.non> wrote in message
> news:4pycnYRbNogO_oWjXTWcrg@comcast.com...
> > I'm a new webmaster for a smaller site that wants to investigate
possible
> > uses for Perl (or CGI ?). I have some background in most computer
> languages,
> > but no experience with Perl and it's code within an internet site.
> >
> > I've ordered a couple of books to study, but I'd like to know about some
> of
> > the better software that's available. I'm sure that I'll want to try and
> > design and test code as I learn, so what are the better/best freeware,
> > shareware, or commercial software choices that are reasonable on costs,
> easy
> > to learn and understand, and to work with.
> >
> > Thanks for any insight.
> >
> > --
> > Change [comcast.non] to [comcast.net]
> >
>
> Please note this group is specific to Perl only and CGI questions are Off
> Topic.
>
> Perl is free. You can download it from http://cpan.org/ports/index.html
>
> Books to read in increasing order of depth/difficulty:
> 1. Learning Perl 3rd Edition - O'Reilly
> 2. Programming Perl 3rd Edition - O'Reilly
>
>
------------------------------
Date: Sun, 05 Jan 2003 19:52:22 GMT
From: Fred <No_Mail_Address@cox.net>
Subject: Re: While loop
Message-Id: <3E188D86.80B7CF24@cox.net>
Fred wrote:
>
> "Jürgen Exner" wrote:
> >
> > Moshe Jacobson wrote:
> > > Fred had nothing better to do than to say:
> > >> I use the following code, but the second while loops forever until I
> > >> stop with Ctrl+Brk:
> > >
> > >> local $/ ;
> > >> while (<IN>){
> > >> while (m/<pre>.+<br>.+<\/pre>/is) {
> > >> s/(<pre>.+?)<br>(.+?<\/pre>)/$1\n$2/sg;
> > >> }
> > >> print $_ ;
> > >> }
> > >
> > > you should just have an if instead of a while in the inner loop and
> > > it'll be fine. The while is a loop. Why are you looping over the same
> > > line? You're already looping over each line with the outer loop.
> >
> > While this is true and your advice should solve the OP's problem, I still
> > wonder why the inner loop doesn't terminate.
> > After executing the substitute there should not be any and <br> left.......
> >
> > .... wait a second. While writing the above it became quite clear to me.
> > There won't be any "<br"> left but what about "<BR>"? The inner loop
> > condition will match a capital "<BR>" but the substitute command will not
> > replace it. Thereby the condition will never become false.
> >
> > jue
>
> 1.) I checked the html file and there are only <br> and no <BR>.
> 2.) If I replace the inner while by if then there is only one single
> replacement in every <pre> ...</pre> string. Not what I want.
> --
> Fred
Sorry - I was not patient enough. The code works, but takes 30 seconds
for a 420k file - much longer than I expected ....
Any ideas for a faster solution?
--
Fred
------------------------------
Date: Sun, 5 Jan 2003 15:16:57 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: While loop
Message-Id: <slrnb1h869.9is.tadmc@magna.augustmail.com>
Fred <No_Mail_Address@cox.net> wrote:
> Fred wrote:
[ wants to replace <br> but only inside of <pre> ]
> Any ideas for a faster solution?
I dunno if this is faster or not, use the Benchmark module
to answer such questions:
s#(<pre>.*?</pre>)# $a=$1; $a =~ s/<br>/\n/gi; $a #gsie;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 5 Jan 2003 23:04:29 +0100
From: "Michael Peuser \(h\)" <post@mpeuser.de>
Subject: Re: While loop
Message-Id: <avaa3j$748$05$1@news.t-online.com>
"Fred" <No_Mail_Address@cox.net> schrieb im Newsbeitrag
news:3E186038.4313B1C1@cox.net...
....
> I use the following code, but the second while loops forever until I
> stop with Ctrl+Brk:
>
> local $/ ;
This sets input to "slurp" mode - the whole file will be input,
thus 'while (<IN>)' is somewhat irritating. You are probably after an
ugly side-effect in that 'while' sometimes keps $_ ....
> while (<IN>){
Now $_ contains the whole file!
> while (m/<pre>.+<br>.+<\/pre>/is) {
Now you select any line containing <pre> <br> </pre> over and over again.
If any should not be changed by the next line this is your endless loop.....
Look out! '.+' is greedy! And you use Single-Line-Option which lets '.'
match also /n - you probably wanted NOT 's'!!
Not however that $_ is not changed and still containds THE WHOLE FILE!
> s/(<pre>.+?)<br>(.+?<\/pre>)/$1\n$2/sg;
This line does the whole work.......
I should say your program works just by chance. Try the following code:
while (my $line =<IN>) {
while ($line =~ s!(<pre>.+?)<br>(.+?</pre>)!$1\n$2!gs) {};
print "...$line"
}
Kindly
Mike
------------------------------
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 4346
***************************************