[31206] in Perl-Users-Digest
Perl-Users Digest, Issue: 2451 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 31 16:09:41 2009
Date: Sun, 31 May 2009 13:09: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 Sun, 31 May 2009 Volume: 11 Number: 2451
Today's topics:
Re: basic directory watcher - sanity check <jack_posemsky@yahoo.com>
Couldn't create Win32::ChangeNotify object on Windows S <jack_posemsky@yahoo.com>
Re: how can perl respond to someone's HTTP POST <john1949@yahoo.com>
Key press question <edgrsprj@ix.netcom.com>
Re: m// <ben@morrow.me.uk>
new CPAN modules on Sun May 31 2009 (Randal Schwartz)
Re: Problems installing Jifty. Test::WWW::Selenium fail <ben@morrow.me.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 31 May 2009 10:49:03 -0700 (PDT)
From: Jack <jack_posemsky@yahoo.com>
Subject: Re: basic directory watcher - sanity check
Message-Id: <ab7669ef-0f24-4f8e-9331-3bc3264f9c65@z7g2000vbh.googlegroups.com>
On May 29, 12:18=A0pm, "A. Sinan Unur" <1...@llenroc.ude.invalid> wrote:
> Jack <jack_posem...@yahoo.com> wrote in news:ea602f6b-9e5e-41a9-8416-
> a24504829...@b1g2000vbc.googlegroups.com:
>
> > I use activestate and they dont support with my version of perl Cpan
> > directory watcher.. is there a better way to watch a directory for a
> > file and then process it than the below, perl, shareware, or through a
> > low cost product ? =A0The infinite loop code below causes my windows
> > server 2003 to have strange behavior after its been running a few days
> > (blinking screen, requiring reboot, etc). =A0I know its related b/c whe=
n
> > this service is stopped, the system is fine. =A0I checked File Monitor
> > also but you still need something that continuously checks something,
> > the array in its case...
>
> > while (1) {
> > @filelist=3D();
> > @filelist =3D split(/\n/, $var =3D `dir /A-D /B /O-D e:\\mail\inboxes\
> > \testbox`);
>
> replace this with
>
> my @filelist =3D ...;
>
> Now, instead of invoking a shell, you can do:
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> while ( 1 ) {
> =A0 =A0 opendir my $dir, '.';
> =A0 =A0 my @files =3D grep { ! /^.{1,2}$/ } readdir $dir;
> =A0 =A0 for my $file ( @files ) {
> =A0 =A0 =A0 =A0 dobasicstuff( $file );
> =A0 =A0 =A0 =A0 movefile( $file );
> =A0 =A0 }
> =A0 =A0 closedir $dir;
> =A0 =A0 sleep 3;
>
> }
>
> __END__
>
> Alternatively, you can try to use the Win32 API Function
> FindFirstChangeNotification
>
> http://msdn.microsoft.com/en-us/library/aa364417(VS.85).aspx
>
> There is a CPAN module to do that:http://search.cpan.org/~cjm/Win32-IPC-1=
.07/lib/Win32/ChangeNotify.pm
>
> --
> A. Sinan Unur <1...@llenroc.ude.invalid>
> (remove .invalid and reverse each component for email address)
>
> comp.lang.perl.misc guidelines on the WWW:http://www.rehabitation.com/clp=
misc/
Hi ok I tried the cpan module you suggested - it worked great on
Windows XP, but then on Windows Server 2003 where I need it (both
running 5.8.8 activestate perl, I get this error:
Couldn't create Win32::ChangeNotify object
Why ?
Code snippet straight from CPAN causing the issue:
use strict;
use POE;
use POE::Component::Win32::ChangeNotify;
my $poco =3D POE::Component::Win32::ChangeNotify->spawn( alias =3D>
'blah' );
POE::Session->create(
package_states =3D> [
'main' =3D> [ qw(_start notification) ],
],
);
------------------------------
Date: Sun, 31 May 2009 10:44:55 -0700 (PDT)
From: Jack <jack_posemsky@yahoo.com>
Subject: Couldn't create Win32::ChangeNotify object on Windows Server, but can on XP
Message-Id: <14b5a954-d51a-47ac-a483-bce3afeeb84a@g19g2000vbi.googlegroups.com>
Hi all, here is a strange one, why would the below CPAN module work
great on Windows XP, but when I run the same code on windows server
2003 (same version of perl activestate 5.8.8), I get the error:
"Couldn't create Win32::ChangeNotify object"
here is the module:
http://search.cpan.org/~bingos/POE-Component-Win32-ChangeNotify-1.18/lib/POE/Component/Win32/ChangeNotify.pm
Code snippet:
use strict;
use POE;
use POE::Component::Win32::ChangeNotify;
my $poco = POE::Component::Win32::ChangeNotify->spawn( alias =>
'blah' );
POE::Session->create(
package_states => [
'main' => [ qw(_start notification) ],
],
);
------------------------------
Date: Sat, 30 May 2009 16:26:23 +0100
From: "John" <john1949@yahoo.com>
Subject: Re: how can perl respond to someone's HTTP POST
Message-Id: <gvrj6q$flj$1@news.albasani.net>
"Jack" <jack_posemsky@yahoo.com> wrote in message
news:718f95f3-5c45-48e0-b544-514be297e8e0@h2g2000yqg.googlegroups.com...
> Hi there,
>
> Simple concept but its not clear anywhere how to implement a response
> to a server (that has posted to my server) with some result. does
> anyone know how, is a CPAN module required to do this ? I have seen
> LWP for posting, but its not clear how to RESPOND to somebody's post
> to my server...
>
> thank you,
> Jack
Hi. I've cut and pasted from my own code.
I guess this is what you need.
Regards
John
#!/usr/bin/perl
# Perl 5.8.8
# MySQL 5.0.32
use lib '../'; # parent directory
use strict;
use warnings;
use XML::Simple; $XML::Simple::PREFERRED_PARSER='XML::Parser';
my $xmlsimple=new XML::Simple (ForceArray=>1, SuppressEmpty=>'',
KeyAttr=>[]); # create object
# ------------------------------------------------------------------------------------------
my $length=$ENV{'CONTENT_LENGTH'};
my $request; my $response;
read (STDIN,$request,$length); # XML request from client
my $data=$xmlsimple->XMLin($request); # parse XML string
my $username=$data->{'username'}->[0];
my $password=$data->{'password'}->[0];
my $number=$data->{'number'}->[0];
if ($username ne 'whatever') {$response="
<whatever-response>
<error-message>invalid username</error-message>
</whatever-response>"
}
else {$response="
<whatever-response>
<company-name>Whatever Limited</company-name>
<company-address>Whatever Town</company-address>
<error-message></error-message>
</whatever-response>"
}
my $len=length($response);
# send 200 back to client via STDOUT - note blank line
print <<END;
Status: 200 OK
Content-type: application/xml;charset=UTF-8
Accept: application/xml;charset=UTF-8
Content-length: $len
$response
END
# ------------------------------------------------------------------------------------------
1; # last statement executed must be true
__END__
------------------------------
Date: Sat, 30 May 2009 23:36:18 -0500
From: "E.D.G." <edgrsprj@ix.netcom.com>
Subject: Key press question
Message-Id: <d8qdnR0PUOnflL_XnZ2dnUVZ_tGdnZ2d@earthlink.com>
This inquiry pertains to Perl's keyboard key reading capabilities.
A slowly expanding international volunteer group of researchers are creating
freeware software for humanitarian efforts such as disaster mitigation
projects. The latest ActiveState version of Perl is being used along with
the Gnuplot program for graphics. The programs are being developed on
regular PC type computers with Windows software. But we want them to be
able to run on a variety of computers and also be used for CGI applications.
Those are two of the reasons for going with Perl. The main problem we are
having has to do with the fact that no one in the group is an experienced
Perl programmer. So we are having to look around for information such as
the following:
Many computer languages have a regular keyboard input statement such as the
Perl readline command. They also usually have commands for reading
individual key presses without the need to hit the Enter key.
The only reference I have been able to find to a keyboard key read statement
involves the IsKeyPressed command in the Win32-GuiTest module. And I was
unable to determine how to use it for two different things that an Inkey or
Getkey statement might do in Basic for example.
How are the Ctrl, Shift, and Alt keys read?
When a key is read using IsKeyPressed, how can the Windows keyboard buffer
be cleared for that key press? IsKeyPressed does not appear to do that.
And the next time a readline statement is encountered the previous key
presses are still there.
Are there other key press read commands available in any of the Perl
modules?
------------------------------
Date: Sun, 31 May 2009 17:48:46 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: m//
Message-Id: <e0paf6-4p5.ln1@osiris.mauzo.dyndns.org>
Quoth "Guy" <someone@somewhere.nb.ca>:
> A user submits a few keywords to search, for example "red barn". I push
> these words in the array @words.
>
> I then want to search through each record of my text database to see if any
> of those keywords (up to four keywords) appear in the description of the
> photos.
>
> I would suspect there is a better way. Would there be a simple way to check
> all submitted keywords, assuming the user could only submit a 50 character
> string?
>
> I suppose too that PDS may not be very descriptive for a hash.
The question you should ask is: in the context of this program, is it
clear what the key is being used for? Without seeing the rest of the
program or knowing what 'PDS' stands for I can't give an opinion on that
:).
> Do I need quotes around PDS?
No. You can omit the quotes (inside the {} of a hash element, or to the
left of the => operator) on any word consisting only of the characters
a-z A-Z 0-9 _
i.e. any word that matches /^\w+$/.
> Note too that this is an array of hashes since $j is sequential between 0
> and n-1.
>
> if ( $info[$j]{'PDS'} =~ /$words[0]|$words[1]|$words[2]|$words[3]/ )
You are matching literal strings, so you need to use \Q in case they
contain regex metacharacters.
I would write this
# before the loop
my $rx = map qr/$_/, join "|", map "\\Q$_\\E", @words;
# inside the loop
if ($info[$j]{PDS} =~ $rx) {
...
}
but you need to make sure you understand how that works before blindly
copying it.
In general, looping over array indices is bad style in Perl. If you have
a loop that looks like this
for (my $j = 0; $j < @info; $j++) {
if ($info[$j]{PDS} =~ $rx) {
...
}
}
it would be better written as
for (@info) {
if ($_->{PDS} =~ /$rx/) {
...
}
}
Ben
------------------------------
Date: Sun, 31 May 2009 04:42:27 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun May 31 2009
Message-Id: <KKHrqr.15EM@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Algorithm-Cluster-1.46
http://search.cpan.org/~mdehoon/Algorithm-Cluster-1.46/
Perl interface to the C Clustering Library.
----
Bio-Graphics-1.95
http://search.cpan.org/~lds/Bio-Graphics-1.95/
Generate GD images of Bio::Seq objects
----
CGI-Inspect-0.2
http://search.cpan.org/~awwaiid/CGI-Inspect-0.2/
Inspect and debug CGI apps with an in-browser UI
----
Catalyst-Controller-WrapCGI-0.017
http://search.cpan.org/~rkitover/Catalyst-Controller-WrapCGI-0.017/
Run CGIs in Catalyst
----
Catalyst-Model-SOAP-1.1
http://search.cpan.org/~druoso/Catalyst-Model-SOAP-1.1/
Map a WSDL to a catalyst model class.
----
Config-Model-0.636
http://search.cpan.org/~ddumont/Config-Model-0.636/
Framework to create configuration validation tools and editors
----
Coro-Mysql-0.1
http://search.cpan.org/~mlehmann/Coro-Mysql-0.1/
let other threads run while doing mysql requests
----
ExtUtils-MakeMaker-6.52
http://search.cpan.org/~mschwern/ExtUtils-MakeMaker-6.52/
Create a module Makefile
----
File-Map-0.14
http://search.cpan.org/~leont/File-Map-0.14/
Memory mapping made simple and safe.
----
GBrowse-1.994
http://search.cpan.org/~lds/GBrowse-1.994/
----
Games-Solitaire-Verify-0.06
http://search.cpan.org/~shlomif/Games-Solitaire-Verify-0.06/
verify solutions for solitaire games.
----
HTML-Template-Compiled-Filter-Whitespace-0.07
http://search.cpan.org/~steffenw/HTML-Template-Compiled-Filter-Whitespace-0.07/
whitespace filter for HTML output
----
HTML-Template-Compiled-Plugin-VBEscape-0.03
http://search.cpan.org/~steffenw/HTML-Template-Compiled-Plugin-VBEscape-0.03/
VB-Script-Escaping for HTC
----
HTML-Tested-JavaScript-0.17
http://search.cpan.org/~bosu/HTML-Tested-JavaScript-0.17/
JavaScript enabled HTML::Tested widgets.
----
IPC-Run3-0.043
http://search.cpan.org/~rjbs/IPC-Run3-0.043/
run a subprocess with input/ouput redirection
----
JSON-XS-2.24
http://search.cpan.org/~mlehmann/JSON-XS-2.24/
JSON serialising/deserialising, done correctly and fast
----
KSx-Search-WildCardQuery-0.03
http://search.cpan.org/~sprout/KSx-Search-WildCardQuery-0.03/
Wild card query class for KinoSearch
----
Lingua-Abbreviate-Hierarchy-0.02
http://search.cpan.org/~andya/Lingua-Abbreviate-Hierarchy-0.02/
Shorten verbose namespaces
----
Lingua-Abbreviate-Hierarchy-0.03
http://search.cpan.org/~andya/Lingua-Abbreviate-Hierarchy-0.03/
Shorten verbose namespaces
----
Lingua-tlhInganHol-yIghun-20090530
http://search.cpan.org/~mschwern/Lingua-tlhInganHol-yIghun-20090530/
"The Klingon Language: hey you, program in it!"
----
Locale-Maketext-TieHash-L10N-0.11
http://search.cpan.org/~steffenw/Locale-Maketext-TieHash-L10N-0.11/
Tying language handle to a hash
----
Locale-Maketext-TieHash-nbsp-1.01
http://search.cpan.org/~steffenw/Locale-Maketext-TieHash-nbsp-1.01/
Tying subroutine to a hash
----
Mail-SpamCannibal-1.00
http://search.cpan.org/~miker/Mail-SpamCannibal-1.00/
A tool to stop SPAM
----
MooseX-POE-0.203
http://search.cpan.org/~perigrin/MooseX-POE-0.203/
The Illicit Love Child of Moose and POE
----
Net-Mosso-CloudFiles-0.43
http://search.cpan.org/~lbrocard/Net-Mosso-CloudFiles-0.43/
Interface to Mosso CloudFiles service
----
Net-Twitter-3.00000
http://search.cpan.org/~mmims/Net-Twitter-3.00000/
A perl interface to the Twitter API
----
Net-Twitter-3.00001
http://search.cpan.org/~mmims/Net-Twitter-3.00001/
A perl interface to the Twitter API
----
ORDB-CPANMeta-Generator-0.01
http://search.cpan.org/~adamk/ORDB-CPANMeta-Generator-0.01/
Generator for the CPAN Meta database
----
Object-Simple-0.0205
http://search.cpan.org/~kimoto/Object-Simple-0.0205/
Light Weight Minimal Object System
----
Object-Simple-0.0207
http://search.cpan.org/~kimoto/Object-Simple-0.0207/
Light Weight Minimal Object System
----
POE-1.006
http://search.cpan.org/~rcaputo/POE-1.006/
portable multitasking and networking framework for Perl
----
POE-Component-Server-POP3-0.08
http://search.cpan.org/~bingos/POE-Component-Server-POP3-0.08/
A POE framework for authoring POP3 servers
----
Padre-Plugin-Ecliptic-0.04
http://search.cpan.org/~azawawi/Padre-Plugin-Ecliptic-0.04/
Padre plugin that provides Eclipse-like useful features
----
Padre-Plugin-Ecliptic-0.05
http://search.cpan.org/~azawawi/Padre-Plugin-Ecliptic-0.05/
Padre plugin that provides Eclipse-like useful features
----
Padre-Plugin-Perl6-0.41
http://search.cpan.org/~azawawi/Padre-Plugin-Perl6-0.41/
Padre plugin for Perl6
----
Params-Util-1.00
http://search.cpan.org/~adamk/Params-Util-1.00/
Simple, compact and correct param-checking functions
----
Parse-Readelf-0.05
http://search.cpan.org/~dorner/Parse-Readelf-0.05/
handle readelf's output with a class
----
Perl-Critic-Itch-0.07
http://search.cpan.org/~marcelo/Perl-Critic-Itch-0.07/
A collection of Perl::Critic Policies to solve some Itches
----
RTx-From-0.03
http://search.cpan.org/~jpierce/RTx-From-0.03/
Make it easier to find users and their tickets
----
SQL-Abstract-1.56
http://search.cpan.org/~ribasushi/SQL-Abstract-1.56/
Generate SQL from Perl data structures
----
Syntax-Highlight-Perl6-0.59
http://search.cpan.org/~azawawi/Syntax-Highlight-Perl6-0.59/
Perl 6 Syntax Highlighter
----
Task-Padre-Plugins-0.21
http://search.cpan.org/~fayland/Task-Padre-Plugins-0.21/
Get many Plugins of Padre at once
----
Test-Able-0.09
http://search.cpan.org/~jdv/Test-Able-0.09/
xUnit with Moose
----
Test-Simple-0.88
http://search.cpan.org/~mschwern/Test-Simple-0.88/
Basic utilities for writing tests.
----
UNIVERSAL-isa-1.02
http://search.cpan.org/~chromatic/UNIVERSAL-isa-1.02/
Attempt to recover from people calling UNIVERSAL::isa as a function
----
Unicode-LineBreak-1.000_01
http://search.cpan.org/~nezumi/Unicode-LineBreak-1.000_01/
UAX #14 Unicode Line Breaking Algorithm
----
WWW-TamperData-0.05
http://search.cpan.org/~marcussen/WWW-TamperData-0.05/
Replay tamper data xml files
----
Xtract-0.10
http://search.cpan.org/~adamk/Xtract-0.10/
Take any data source and deliver it to the world
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
Date: Sun, 31 May 2009 17:30:17 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Problems installing Jifty. Test::WWW::Selenium fails b/c Test::Mock::LWP? Not sure...
Message-Id: <ptnaf6-4p5.ln1@osiris.mauzo.dyndns.org>
Quoth JC <jim.x.kc@gmail.com>:
> While installing Jifty via cpanplus it "threw me in" the "old cpan" to
> install the 'Test::Mock::LWP' module, which was required for the
> Test::WWW::Selenium module to be installed. After just "going with the
> flow" and switching over into the cpan the installed failed. I am not
> sure why and was wondering if anyone else has had this problem. My
> version of Perl is 5.10. I am not sure what other information I should
> give besides I usually always use the default choice when asked a
> question vai cpanplus/cpan. Thanks in advance.
>
>
> # Below is the tail end of the cpanplus .log file:
<snip>
> *** Module::AutoInstall version 1.02
> *** Checking for Perl dependencies...
> [Core Features]
> - Test::More ...loaded. (0.86 >= 0.42)
> - Test::Exception ...loaded. (0.27)
> - Test::Mock::LWP ...missing.
> - Test::Pod ...loaded. (1.26)
> - LWP::UserAgent ...loaded. (5.826)
> - URI::Escape ...loaded. (3.29 >= 1.31)
> ==> Auto-install the 1 mandatory module(s) from CPAN? [y]
This is your problem. This is a bug in Test::WWW::Selenium: the author
should have released a new version with an updated version of
Module::Install, and in any case AutoInstall is deprecated nowadays.
Download the tarball, unpack it, edit the Makefile.PL to remove the line
auto_install;
tar it up again, and then run
cpanp -i file:///path/to/Test-WWW-Selenium.tar.gz
This should correctly install T::W::S and all its dependancies, at which
point you should be able to install Jifty. You may want to report this
to the T::W::S bugtracker.
Ben
------------------------------
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 V11 Issue 2451
***************************************