[24180] in Perl-Users-Digest
Perl-Users Digest, Issue: 6372 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 7 14:05:46 2004
Date: Wed, 7 Apr 2004 11:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 7 Apr 2004 Volume: 10 Number: 6372
Today's topics:
Re: [VERY OT] a linguistic question (.sig-related, xpos <keith.davies@kjdavies.org>
Re: [VERY OT] a linguistic question (.sig-related, xpos <xxala_qumsiehxx@xxyahooxx.com>
Re: Autoflush for DB_FILE to share a hash among coopera <dwilga-MUNGE@mtholyoke.edu>
display Excel file in browser? <bdu@iastate.edu>
file access trouble <EatMeSpammers_cwtart@commpay.tv>
Re: file access trouble <tore@aursand.no>
Re: free source for bbs <remorse@partners.org>
Re: More NET::LDAP questions (Steve The Geek)
Re: Optimizing using precompiled Perl program? ctcgag@hotmail.com
Re: Perl and Internet Explorer (akaliel)
Re: Problem installing Net::DNS (Ken Bailey)
Re: Regular expression question (Kapil Khosla)
Re: Regular expression question (Kapil Khosla)
Re: Regular expression question <ittyspam@yahoo.com>
Running a perl script in the background on Windows (Stephen M)
Re: Running a perl script in the background on Windows <ittyspam@yahoo.com>
Re: scoping, sig handlers, and labels ctcgag@hotmail.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 07 Apr 2004 15:15:39 GMT
From: Keith Davies <keith.davies@kjdavies.org>
Subject: Re: [VERY OT] a linguistic question (.sig-related, xposted)
Message-Id: <slrnc786or.2np.keith.davies@kjdavies.kjdavies.org>
On Wed, 07 Apr 2004 15:15:40 +0200, Michele Dondi <bik.mido@tiscalinet.it> wrote:
> I'm sorry for this OT, but these seemed to me the best NGs, amongst
> those that I subscribe, to ask this question, and I don't know where
> else I could do it.
>
> I like to gather witty cmts or otherwise interesting sentences from
> USENET posts to quote in .sigs: now I have a doubt about the
> preposition to use when citing the author, i.e. should I use
>
> > utterly stupid claim
> witty cmt
> - J. Random Hacker in comp.foo.bar, "Re: Fred Mbogo"
> ^^
>
> or
>
> > utterly stupid claim
> witty cmt
> - J. Random Hacker on comp.foo.bar, "Re: Fred Mbogo"
> ^^
FWIW, I don't bother with either; from my current .sig:
"Your ability to bang your head against reality in the hope that
reality will crack first is impressive, but futile"
-- Geoffrey Brent, rec.games.frp.dnd
Keith
--
Keith Davies "Your ability to bang your head against
keith.davies@kjdavies.org reality in the hope that reality will
crack first is impressive, but futile"
-- Geoffrey Brent, rec.games.frp.dnd
------------------------------
Date: Wed, 07 Apr 2004 16:31:17 GMT
From: Ala Qumsieh <xxala_qumsiehxx@xxyahooxx.com>
Subject: Re: [VERY OT] a linguistic question (.sig-related, xposted)
Message-Id: <p1Wcc.19356$Mt1.12411@newssvr27.news.prodigy.com>
Michele Dondi wrote:
> > utterly stupid claim
> witty cmt
> - J. Random Hacker in comp.foo.bar, "Re: Fred Mbogo"
> ^^
>
> or
>
> > utterly stupid claim
> witty cmt
> - J. Random Hacker on comp.foo.bar, "Re: Fred Mbogo"
> ^^
I might be wrong, but I would think people write *in* posts *on* newsgroups.
But, why do you care? Most newsreaders strip out .sigs anyway :)
--Ala
------------------------------
Date: Wed, 07 Apr 2004 11:33:22 -0400
From: Dan Wilga <dwilga-MUNGE@mtholyoke.edu>
Subject: Re: Autoflush for DB_FILE to share a hash among cooperating processes?
Message-Id: <dwilga-MUNGE-01D28D.11332207042004@nap.mtholyoke.edu>
In article <40200384.0404070628.7c720d3b@posting.google.com>,
axelboldt@yahoo.com (Axel Boldt) wrote:
> Hello,
>
> I want to share a hash variable among several forked processes.
> Ideally I would use threads and threads::shared, but I need LWP which
> is not thread-safe. So I thought about using DB_FILE and a hash
> variable tied to the same file in each of the processes. If one
> process changes the hash variable, all others should see the change
> immediately. I.e. I want that the change is immediately flushed to
> disk, and that every access to the hash variable takes its value
> directly from disk, not from some internal cache. Is that possible? I
> have tried the O_SYNC flag for db_open and also the $db->sync() method
> to no avail.
I would recommend using the BerkeleyDB module instead of DB_File, and
then using the DB_INIT_MPOOL and DB_INIT_CDB flags in a call to
BerkeleyDB::Env.
Anything less complex will lead to synchronization problems, since there
is no record locking in Berkeley DB, unless you use either CDB or full
transactional mode.
--
Dan Wilga dwilga-MUNGE@mtholyoke.edu
** Remove the -MUNGE in my address to reply **
------------------------------
Date: Wed, 07 Apr 2004 10:28:46 -0500
From: Bing Du <bdu@iastate.edu>
Subject: display Excel file in browser?
Message-Id: <c516nl$9tn$1@news.iastate.edu>
Greetings,
I've used Spreadsheet::WriteExcel to generate a spreadsheet. Now I need
this spreadsheet to be viewable in web browsers. I can _not_ put any
files under the web server document root directory due to the privilege
restrictions. So this has failed my idea of creating a link on the web
page and making the link point to the spreadsheet.
The best place for me to store the sheet is in the /tmp directory. If I
use the following code to load my.xls into $bindata, how can I display
$bindata in its original spreadsheet format on the web?
======
$spreadsheet = "/tmp/my.xls";
open(F,$spreadsheet);
read(F,$bindata,-s F);
close(F);
======
I've checked Spreadsheet::ParseExcel. But it's not what I want because
I don't want to extract information from my.xls.
Appreciate any ideas in advance.
Bing
------------------------------
Date: Wed, 7 Apr 2004 10:24:19 -0500
From: "Chuck" <EatMeSpammers_cwtart@commpay.tv>
Subject: file access trouble
Message-Id: <G2Vcc.841$KG2.1636@reggie.win.bright.net>
I am a new user to perl - trying to teach myself enough perl to do a
specific task to be used in conjunction with other software I have
developed.
I am a software developer and use a web site for distribution of the
software. The download folder of this web site uses password protection via
.htpasswd
I created another windows based program that creates the .htpasswd file
locally - each of my software users has their own username and password to
download updates to the software - what I need to do with perl is to loop
through the local .htpasswd file that is created by the other windows app
and crypt() the password. I have already done this by looping through the
local .htpasswd file in my windows based code and copying the password to be
encrypted to the local clipboard on the computer that I use to maintain my
user list. Then I call perl from within my windows based code, get the data
from the clipboard, crypt() the password, and then copy it back to the
clipboard, then get the clipboard data in my windows based code, and update
the local .htpasswd file with the encrypted string for the password. Then
after the process is done I use FTP to upload the .htpasswd file to the
protected folder on the web server. This all works great but I want to loop
through the entire file using perl rather that calling perl for each record
in the file - this is rather slow because perl needs to be loaded for each
record in the local .htpasswd file rather than only loading once.
I have been through several tutorials and did google searches to see if I
could determine why my perl script is not working but could not get it to
work. I ran the script though the perl debugger and made sure there were no
errors in the script that the debugger could find. I am using wperl.exe so
the console window does not show but have also used perl.exe.
I have been working on this for a couple of days but figured that some help
from the perl experts could expedite this for me. Any suggestions or
pointers will be greatly appreciated.
The script runs without any error messages but does not appear to read data
from the already existing .htpasswd file and it does not create the new
.htpasswd2 file that I rename to the original file name after the loop is
finished - this is my script;
use strict;
use warnings;
my $text1;
my $text2;
my $OldFile = "c:\\cwicweb\\exec\\commpay\\shared data\\.htpasswd";
my $NewFile = "c:\\cwicweb\\exec\\commpay\\shared data\\.htpasswd2";
open(OLD, '<', $OldFile) or die "$!\n";
open(NEW, '>', $NewFile) or die "$!\n";
while (<OLD>) {
$text1 = substr($_,0,5);
$text2 = crypt(substr($_,5,8),substr($_,13,2));
print NEW "$text1 $text2 /n";
}
close OLD or die "$!\n";
close NEW or die "$!\n";
rename($NewFile,$OldFile) or die "$!\n";
The files do not need to be locked as only one person will be running this
script at any given time.
--
regards,
Chuck
CommPay Software
------------------------------
Date: Wed, 07 Apr 2004 19:30:18 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: file access trouble
Message-Id: <pan.2004.04.07.17.08.43.531087@aursand.no>
On Wed, 07 Apr 2004 10:24:19 -0500, Chuck wrote:
> my $text1;
> my $text2;
You don't need these.
> my $OldFile = "c:\\cwicweb\\exec\\commpay\\shared data\\.htpasswd";
> my $NewFile = "c:\\cwicweb\\exec\\commpay\\shared data\\.htpasswd2";
No need for double quotes here. Save yourself trouble by doing this:
my $OldFile = 'c:/cwicweb/exec/company/shared data/.htpasswd';
my $NewFile = 'c:/cwicweb/exec/company/shared data/.htpasswd2';
> while (<OLD>) {
> $text1 = substr($_,0,5);
> $text2 = crypt(substr($_,5,8),substr($_,13,2));
> print NEW "$text1 $text2 /n";
> }
Could have been written as:
while ( <OLD> ) {
my $text1 = substr( $_, 0, 5 );
my $text2 = crypt( substr($_, 5, 8), substr($_, 13, 2) );
print NEW "$text1 $text2 \n";
}
Other than that, I don't see any "errors" in your script. Are you sure
there aren't any error messages?
--
Tore Aursand <tore@aursand.no>
"A teacher is never a giver of truth - he is a guide, a pointer to the
truth that each student must find for himself. A good teacher is
merely a catalyst." -- Bruce Lee
------------------------------
Date: Wed, 07 Apr 2004 13:47:43 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: free source for bbs
Message-Id: <remorse-561B42.13474307042004@plato.harvard.edu>
In article <0a0q60lurrafl2o97721974kkauobvdj0b@4ax.com>,
Henry Law <lawshouse.public@btconnect.com> wrote:
> On Thu, 01 Apr 2004 19:34:31 -0500, Chris Mattern
> <matternc@comcast.net> wrote:
>
> >You can't trick me, I know an April Fool's post when
> >I see one!
>
> Alas not:
>
> Date: Thu, 1 Apr 2004 12:55:02 -0800
>
> ... after mid-day, y'see. Or is that just a British restriction?
Although not, by any stretch of the imagination, an expert, over here in
the USA, April Fools tricks may happen even in the afternoon. At least,
where I was brought up they could. Perhaps this differs around the
country.
Ricky
--
Pukku
------------------------------
Date: 7 Apr 2004 10:32:59 -0700
From: slkleine@hotmail.com (Steve The Geek)
Subject: Re: More NET::LDAP questions
Message-Id: <863f122c.0404070932.4b7ac176@posting.google.com>
> > According to MS, an LDAP query of
> > (useraccountcontrol:1.2.840.113556.1.4.803:=2) should pull up all
> > expired accounts. From the LDP utility in the Windows 2000 resource
> > kit, it works.
> > Any thoughts of why the easier 1.2.840.113556.1.4.803:=2 won't work?
> Actually, the example code download at:
> http://www.winnetmag.com/Articles/ArticleID/38058/pg/3/3.html
> gives me a hint. Listing 3 has these lines:
>
> ...
> sub LDAP_CONTROL_TREE_DELETE () { "1.2.840.113556.1.4.805" }
> ...
> my $treedelc = Net::LDAP::Control->new( LDAP_CONTROL_TREE_DELETE );
> $rc = $ldap->delete($dn_to_delete, control => [ $treedelc ]);
> ...
>
> so maybe you can create your own control with that OID that you have and
> use that in the search() call.
Took the advice.
###new code snippets:
my $LogicalOrOid = Net::LDAP::Control->new(
type => "1.2.840.113556.1.4.803",
critical => "1",
value => "LDAP_MATCHING_RULE_BIT_AND"
);
...
$mesg = $ldap->search( # perform a search on all useful permutations
of "accountDisabled"
base => 'DC=workplace,DC=com',
scope => 'sub',
sizelimit => '1',
filter => '(useraccountcontrol=2)',
control => [$LogicalOrOid],
attrs => ['memberof',
'samaccountname',
'homedirectory',
'name',
'distinguishedname',
'lastlogon'],
);
### End new code snippets
Now it kicks back a whole new error:
00000057: LdapErr: DSID-0C090591, comment: Error processing control,
data 0, v893l line 55
Mind you, if I change the filter criteria to '(useraccountcontrol=*)'
it returns all users without fail. No other filter value in
useraccountcontrol works.
According to MS[1] this error is the result of a second request
arriving at the LDAP server prior to results coming back for the first
one. They claim[2] this was fixed in W2K SP4.
We *are* running SP4, and the files referenced in the KB article are
up-to-date. And, as the snippet above shows, I've set sizelimit => "1"
-- in theory, this should cause the queries to wait for one response
before sending another.
Furrfu.
I'm of the mindset that this is a MS problem and no longer a perl one.
:-/
Steve the (anyone have the coordinates for Redmond WA handy?) Geek
[1] http://support.microsoft.com/default.aspx?kbid=329727
[2] for values of 'claim' that include 'because we say so'...
------------------------------
Date: 07 Apr 2004 17:53:13 GMT
From: ctcgag@hotmail.com
Subject: Re: Optimizing using precompiled Perl program?
Message-Id: <20040407135313.985$xU@newsreader.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> Yash <yashgt@yahoo.com> wrote in comp.lang.perl.misc:
> > We have a compute-intensive Perl program that needs optimization. We
> > have done whatever we could on the algorithm front. Would it give any
> > performnace improvement if we convert the program to bytecode using:
> > perl -MO=Bytecode[,-H][,-oscript.plc] script.pl
> >
> > We are looking for overall runtime performance improvement and not
> > just initial load-time improvement.
> >
> > Can you suggest anything else for further optimization?
>
> Profile it to find possible hot spots. Devel::Dprof is the tool.
I often find Devel::SmallProf more useful, especially for smaller projects.
Usually I already know what sub is consuming the time, and I want to know
which line within the sub is the hog.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 7 Apr 2004 08:58:40 -0700
From: akaliel@streamflo.com (akaliel)
Subject: Re: Perl and Internet Explorer
Message-Id: <7123bc57.0404070758.43f13121@posting.google.com>
> I assume you've already tried the following http header to specify a default
> filename?
>
> Content-Disposition: attachment; filename=[FILENAME]
>
> If so, then I'm out of ideas...
>
> Matt
Umm, no I hadn't. But I tried it and lo! It worked! More
specifically, I had to enter the following perl code to handle ppt and
exe files accordingly:
my $attachment;
if ($type_name eq 'PowerPoint Presentation') {
$attachment = "$filename.ppt";
}
elsif ($type_name eq 'EXE File') {
$attachment = "$filename.exe";
}
else {
$attachment = "";
}
print $q->header({-disposition=>'inline',
-type=>$header,
-attachment=>$attachment});
while (<FILE>) {
print $_;
}
close(FILE);
$| = 0; # turn on buffering of stdout
I'm going to clean it up a bit by actually having a mysql table handle
that bit of hardcoding I added that decides the proper extension for
the given file type. But it worked great. Thanks for all your help.
Allan
------------------------------
Date: 7 Apr 2004 10:59:52 -0700
From: K.Bailey@rbgkew.org.uk (Ken Bailey)
Subject: Re: Problem installing Net::DNS
Message-Id: <21204f01.0404070959.1d7435f6@posting.google.com>
> Well, the exact same process works on several other machines... :-) I
> really doubt it's a bug in the code... more it seems more like some sort
> of issue with the host itself. Ahh well...
I had a similar problem that turned out to be host firewall rules
blocking DNS queries to non-local resolvers.
------------------------------
Date: 7 Apr 2004 09:50:37 -0700
From: khoslakapil@yahoo.com (Kapil Khosla)
Subject: Re: Regular expression question
Message-Id: <919aa2da.0404070850.305acf7a@posting.google.com>
I figured this out based on your previous post.
I have attached the code below.
Thanks.
open I, "E:\\mycode\\perl\\brace.txt" or die"Could not open file";
local $/ = undef;
$line = <I>;
$line =~ s/\s*int main\(.*\)\s*\{\s*return\s*main\(.*\)\s*\;\s*\}//g;
print $line;
close I;
Tore Aursand <tore@aursand.no> wrote in message news:<pan.2004.04.07.05.16.23.198926@aursand.no>...
> On Tue, 06 Apr 2004 22:05:32 -0700, Kapil Khosla wrote:
> > I am trying to match the expression
> >
> > #brace.txt
> > int main()
> > {
> > return main();
> > }
> >
> > in a file but am getting stuck somewhere. This is the code I could write
> > till now.
> >
> > open I, "E:\\mycode\\perl\\brace.txt";
>
> Always (!) check if open() succeeds, and drop the double quotes; they're
> not necessary here;
>
> open(I, '<', 'e:\mycode\perl\brace.txt') or die "$!\n";
>
> > while($line = <I>)
> > {
> > $line =~ s/int main\(\)\s*\{return\s*main\(\)\;\s*\}/matched/;
> > print $line;
> > }
>
> You're trying to match multiple lines. The code above will try to match
> only one line at a time. You should consider reading your whole file into
> one string and _then_ do the matching.
------------------------------
Date: 7 Apr 2004 10:12:00 -0700
From: khoslakapil@yahoo.com (Kapil Khosla)
Subject: Re: Regular expression question
Message-Id: <919aa2da.0404070912.17063ef4@posting.google.com>
Allright,
I just read your post. This came in after I replied so my apologies.
What do you mean by "Dont top post".
I am sure this would be somewhere in the documentation but I have been
going through
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html#must
but could not find what it means.
Thanks,
Kapil
> On Wed, 07 Apr 2004 06:07:28 -0700, Kapil Khosla wrote:
> > Great ! Thanks.
>
> Don't top post, and read the posting guidelines posted in this newsgroup
> regularly.
>
> > I modified my script to
> >
> > open I, "E:\\mycode\\perl\\brace.txt" or die"Could not open file";
>
> You listened to something that I wrote in my previous message. That's
> good. Why didn't you listen to everything I said? You don't have to
> worry about escaping the backslashes if you stay with single quote. You
> also want to know _what_ went wrong (which is stored in '$!').
>
> > while($line = <I>)
> > {
> > $line =~ s/\s*int main\(.*\)\s*{?//g;
> > $line =~ s/\s*\{.*//g;
> > $line =~ s/\s*return main\(.*\)\;//g;
> > $line =~ s/\}//g;
> > print $line;
> > }
>
> I think you misunderstood my previous post: You need to _match_ on more
> than one line in 'brace.txt'. You don't need to do the match (or the
> substitution) in more than one line.
>
> > The input file looks like [...]
>
> Why didn't you tell us this the first time you posted?
>
> > int main()
> > {
> > // Do something
> > }
> >
> > int main()
> > {
> > return main();
> > }
> >
> > I only want to delete the second instance of the main block and not
> > the first instance. The code I wrote above deletes the main from the
> > first block too.
>
> First of all - you have to read the _entire_ as a string. Then you need
> to match on something _possibly_ followed by something similar.
>
> Read the Perl documentation for matching nested structures;
>
> perldoc -q match
------------------------------
Date: Wed, 7 Apr 2004 13:36:03 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Regular expression question
Message-Id: <20040407133105.Q14622@dishwasher.cs.rpi.edu>
On Wed, 7 Apr 2004, Kapil Khosla wrote:
> Allright,
> I just read your post. This came in after I replied so my apologies.
> What do you mean by "Dont top post".
> I am sure this would be somewhere in the documentation but I have been
> going through
> http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html#must
>
> but could not find what it means.
> Thanks,
> Kapil
>
Do you see how your replies are always at the top of the message, with the
quoted text below them? Do you see how mine right now (and most others)
are below what I'm quoting? That's the difference. What you are doing is
top-posting. It's considered rude because you can't read a 'conversation'
straight through by starting at the top and going to the bottom. If you
bottom-post, like you're supposed to, the email thread is far easier to
read by all involved.
This policy can be found at the section entitled "Use an effective
followup style " both at the URL you posted as well as the Posting
Guidelines sent to this group itself.
Paul Lalli
------------------------------
Date: 7 Apr 2004 08:09:26 -0700
From: ruggles@lovemail.com (Stephen M)
Subject: Running a perl script in the background on Windows
Message-Id: <4abf1b05.0404070709.3aaba6dc@posting.google.com>
If i want to run a perl script in Windows from Task Scheduler every few minutes.
Is there an option to run it without displaying in a dos type window?
Thanks
Stephen
------------------------------
Date: Wed, 7 Apr 2004 11:14:05 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Running a perl script in the background on Windows
Message-Id: <20040407111313.X14622@dishwasher.cs.rpi.edu>
On Wed, 7 Apr 2004, Stephen M wrote:
> If i want to run a perl script in Windows from Task Scheduler every few minutes.
>
> Is there an option to run it without displaying in a dos type window?
Presuming you are running the ActiveState installation of Perl, just use
wperl.exe instead of perl.exe to run the script. No command-line window
will be associated with it.
Paul Lalli
------------------------------
Date: 07 Apr 2004 16:12:34 GMT
From: ctcgag@hotmail.com
Subject: Re: scoping, sig handlers, and labels
Message-Id: <20040407121234.198$UT@newsreader.com>
Bill <wherrera@lynxview.com> wrote:
> ctcgag@hotmail.com wrote:
> > I expect the program below to go into an infinite loop after print 9,
> >
> > #perl -w
> > use strict;
> > REDO:foreach(1..1000) {
> > $SIG{ALRM}=sub {redo REDO};
> > alarm 10;
> > system "sleep $_"; # don't use builtin sleep, just in case.
> > alarm 0;
> > print "$_\n";
> > };
>
> from perlfunc:
> ===
> It is usually a mistake to intermix alarm and sleep calls. (sleep may be
> internally implemented in your system with alarm)
That's why I shelled out to do the sleep, not that it makes any difference.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 6372
***************************************