[30537] in Perl-Users-Digest
Perl-Users Digest, Issue: 1780 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 8 18:09:43 2008
Date: Fri, 8 Aug 2008 15:09:09 -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 Fri, 8 Aug 2008 Volume: 11 Number: 1780
Today's topics:
Can't bring program to foreground via GUI mark.montemuro@sig.com
Re: Can't bring program to foreground via GUI <smallpond@juno.com>
Re: CLPM - a help group? <RedGrittyBrick@SpamWeary.foo>
Re: CLPM - a help group? <cwilbur@chromatico.net>
Re: CLPM - a help group? <cwilbur@chromatico.net>
GromPerl persistent Perl interpreter [ANN] <gromnospam@googlemail.com>
Re: GromPerl persistent Perl interpreter [ANN] <fawaka@gmail.com>
Re: GromPerl persistent Perl interpreter [ANN] <gromnospam@googlemail.com>
How do I compare strings non-ascii-betically? <suzanne.dorman@sbcglobal.net>
Re: How do I compare strings non-ascii-betically? <bill@ts1000.us>
Re: How do I compare strings non-ascii-betically? <jimsgibson@gmail.com>
Re: How do I compare strings non-ascii-betically? <mark.clementsREMOVETHIS@wanadoo.fr>
Re: How to check for filetype existence quickly xhoster@gmail.com
Re: Need help with perlxs and C strings <th@example.invalid>
Re: Need help with perlxs and C strings xhoster@gmail.com
Re: OO Perl <Peter@PSDT.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 8 Aug 2008 11:55:21 -0700 (PDT)
From: mark.montemuro@sig.com
Subject: Can't bring program to foreground via GUI
Message-Id: <7152c877-5fd3-4678-ad16-61914b695540@25g2000hsx.googlegroups.com>
I'm trying to bring a minimized program to the foreground. The
following program is a sample of what I'm trying to do. I am running
on XP Pro. The paint program is launched, but minimized.
Any help would be welcome.
C:\Perl\Win32-GuiTest-1.54\eg>active.pl
Windows:1843712:
* Could not set the window id: 1843712 active
* Window id: 1843712 brought to foreground <<<This never did
happen, even though it said so
1843712> 'untitled - Paint'
use Win32::GuiTest qw(:ALL);
use Win32::GUI;
$Win32::GuiTest::debug = 0; # Set to "1" to enable verbose mode
my @windows = FindWindowLike(0, "Paint", "");
print "Windows:@windows:\n";
for (@windows) {
$window=$_;
Win32::GUI::BringWindowToTop($window);
my $success = 1;
if ( SetActiveWindow($window) ) {
print "* Successfully set the window id: $window active\n";
}
else {
print "* Could not set the window id: $window active\n";
$success = 0;
}
if (SetForegroundWindow($window) ) {
print "* Window id: $window brought to foreground\n";
}
else {
print "* Window id: $window could not be brought to foreground
\n";
$success = 0;
}
print "$_>\t'", GetWindowText($_), "'\n";
SendKeys("%f");
}
------------------------------
Date: Fri, 8 Aug 2008 13:24:17 -0700 (PDT)
From: smallpond <smallpond@juno.com>
Subject: Re: Can't bring program to foreground via GUI
Message-Id: <96c94fe2-3d34-4dbb-a478-6511dc3cc7e6@c58g2000hsc.googlegroups.com>
On Aug 8, 2:55 pm, mark.montem...@sig.com wrote:
> I'm trying to bring a minimized program to the foreground. The
> following program is a sample of what I'm trying to do. I am running
> on XP Pro. The paint program is launched, but minimized.
>
> Any help would be welcome.
>
> C:\Perl\Win32-GuiTest-1.54\eg>active.pl
> Windows:1843712:
> * Could not set the window id: 1843712 active
> * Window id: 1843712 brought to foreground <<<This never did
> happen, even though it said so
> 1843712> 'untitled - Paint'
>
> use Win32::GuiTest qw(:ALL);
> use Win32::GUI;
You seem to be missing:
use strict;
use warnings;
> Win32::GUI::BringWindowToTop($window);
I don't see this call in the CPAN docs.
--S
------------------------------
Date: Fri, 08 Aug 2008 14:51:13 +0100
From: RedGrittyBrick <RedGrittyBrick@SpamWeary.foo>
Subject: Re: CLPM - a help group?
Message-Id: <489c4f53$0$2929$fa0fcedb@news.zen.co.uk>
Adam Worrall wrote:
<rant omitted>
According to Google Groups you've made no contribution to this newsgroup
in the last decade. You now pop up and your only action is to start
telling regular contributors how they should be behaving.
Bye.
--
RGB
------------------------------
Date: Fri, 08 Aug 2008 09:55:11 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: CLPM - a help group?
Message-Id: <86myjnk3wg.fsf@mithril.chromatico.net>
>>>>> "AW" == Adam Worrall <worrall+unet@cs.bris.ac.uk> writes:
>> But no matter. You're just another shithead who won't be around
>> in a year when I'm still answering questions and helping people.
AW> I would expect you, the FAQ maintainer of all people, to present
AW> yourself in the way you yourself would like to be treated,
AW> rather than attempting to refute an argument with a "fuck you."
Were you making an actual argument, rather than simply a ludicrous and
insulting attempt at proof by repeated assertion, you might be
correct.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Fri, 08 Aug 2008 09:53:26 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: CLPM - a help group?
Message-Id: <86r68zk3zd.fsf@mithril.chromatico.net>
>>>>> "AW" == Adam Worrall <worrall+unet@cs.bris.ac.uk> writes:
AW> Why is it you and various others who support your side can
AW> assert what is and isn't right yet when you see someone else
AW> doing the same for the opposite for what you believe, it is
AW> suddenly wrong? Why the double standard?
Because Tad and the "various others who support [his] side" are people
who have spent years posting to clpm and who are responsible, in part
for making it what it is; and you appear, as near as I can tell, to just
have shown up for this particular thread.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Fri, 8 Aug 2008 14:15:24 +0200
From: "Gvdc net" <gromnospam@googlemail.com>
Subject: GromPerl persistent Perl interpreter [ANN]
Message-Id: <g7hdpo$9mi$1@news.eunet.yu>
GromPerl persistent Perl interpreter
--------------------------------------
GromPerl is persistent Perl interpreter for Unix-like operating systems
provided by Bauk web server's Grom persistent interpreter connector library.
Perl interpreter compiled and linked with Grom persistent interpreter
connector library produces Perl interpreter capable of operating in
persistent mode and executing *.pl scripts in web directory.
Download:
http://www.bauk.ws/gromperl.html
http://www.bauk.ws/readme.html#gromconnector
Demo script:
http://www.bauk.ws/print_date.pl
GromPerl persistent Perl interpreter
Grom persistent interpreter connector library
------------------------------
Date: 08 Aug 2008 15:43:05 GMT
From: Leon Timmermans <fawaka@gmail.com>
Subject: Re: GromPerl persistent Perl interpreter [ANN]
Message-Id: <489c6989$0$49588$e4fe514c@news.xs4all.nl>
On Fri, 08 Aug 2008 14:15:24 +0200, Gvdc net wrote:
> GromPerl persistent Perl interpreter
> --------------------------------------
>
> GromPerl is persistent Perl interpreter for Unix-like operating systems
> provided by Bauk web server's Grom persistent interpreter connector
> library.
>
> Perl interpreter compiled and linked with Grom persistent interpreter
> connector library produces Perl interpreter capable of operating in
> persistent mode and executing *.pl scripts in web directory.
>
>
> Download:
> http://www.bauk.ws/gromperl.html
> http://www.bauk.ws/readme.html#gromconnector
>
> Demo script:
> http://www.bauk.ws/print_date.pl
>
>
> GromPerl persistent Perl interpreter
> Grom persistent interpreter connector library
This is the third time in three months you post this crap. If you are
making an announcement, at least put some news in it...
Leon
------------------------------
Date: Fri, 8 Aug 2008 19:36:21 +0200
From: "Gvdc net" <gromnospam@googlemail.com>
Subject: Re: GromPerl persistent Perl interpreter [ANN]
Message-Id: <g7i06p$fr5$1@news.eunet.yu>
"Leon Timmermans" wrote in message ...
>> GromPerl persistent Perl interpreter
>> Grom persistent interpreter connector library
>
> This is the third time in three months you post this crap. If you are
> making an announcement, at least put some news in it...
>
> Leon
Dear colleague please give us a link to your recent
work, to have a look.
------------------------------
Date: Fri, 8 Aug 2008 10:30:00 -0700 (PDT)
From: Suzanne <suzanne.dorman@sbcglobal.net>
Subject: How do I compare strings non-ascii-betically?
Message-Id: <438d782f-7259-4808-89ed-14fb6511a1dc@25g2000hsx.googlegroups.com>
I am new to Perl but I did a lot of web searching and haven't found an
answer to my problem.
I have to compare strings that are version numbers. I want to know if
a version number is less than or equal to another version number.
For example, version 3.2 is less than version 3.16. But when I
compare them, 3.16 is considered less. I tried the cmp function and
got the same results.
I could strip the contents after the '.' and compare them numerically
but it becomes difficult if the version number is 3.2.1.5 (for
example).
Any ideas? Thanks in advance.
------------------------------
Date: Fri, 8 Aug 2008 11:33:12 -0700 (PDT)
From: Bill H <bill@ts1000.us>
Subject: Re: How do I compare strings non-ascii-betically?
Message-Id: <a2733e93-25fd-4e2f-9289-2d85b34197f6@c65g2000hsa.googlegroups.com>
On Aug 8, 1:30=A0pm, Suzanne <suzanne.dor...@sbcglobal.net> wrote:
> I am new to Perl but I did a lot of web searching and haven't found an
> answer to my problem.
>
> I have to compare strings that are version numbers. =A0I want to know if
> a version number is less than or equal to another version number.
>
> For example, version 3.2 is less than version 3.16. =A0But when I
> compare them, 3.16 is considered less. =A0I tried the cmp function and
> got the same results.
>
> I could strip the contents after the '.' and compare them numerically
> but it becomes difficult if the version number is 3.2.1.5 (for
> example).
>
> Any ideas? =A0Thanks in advance.
One way would be to split the versions on the ".", pad with zeros and
compare that way. Example (untested, typed in):
@versions =3D ("3.16","3.2");
for($i =3D 0;$i < @versions;$i++)
{
@thisone =3D split(/\./,$versions[$i]);
$temp =3D "";
foreach $a (@thisone)
{
$temp .=3D sprintf("%08i",$a);
}
$newversion[@newversion] =3D $temp."\t".$versions[$i];
}
@sorted =3D sort @newversion;
for($i =3D 0;$i < @sorted;$i++)
{
@this =3D split(/\t/,$sorted[$i]);
print "$this[1]\n";
}
Brute force, should work, could be improved with a hammer
Bill H
------------------------------
Date: Fri, 08 Aug 2008 12:01:10 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: How do I compare strings non-ascii-betically?
Message-Id: <080820081201100502%jimsgibson@gmail.com>
In article
<438d782f-7259-4808-89ed-14fb6511a1dc@25g2000hsx.googlegroups.com>,
Suzanne <suzanne.dorman@sbcglobal.net> wrote:
> I am new to Perl but I did a lot of web searching and haven't found an
> answer to my problem.
>
> I have to compare strings that are version numbers. I want to know if
> a version number is less than or equal to another version number.
>
> For example, version 3.2 is less than version 3.16. But when I
> compare them, 3.16 is considered less. I tried the cmp function and
> got the same results.
>
> I could strip the contents after the '.' and compare them numerically
> but it becomes difficult if the version number is 3.2.1.5 (for
> example).
>
> Any ideas? Thanks in advance.
You need a multi-level comparison function that will split the two
input strings into parts separated by periods and compare each
corresponding part left to right, returning a comparison value for the
first difference it finds. Something like:
sub compare_version
{
my( $x, $y ) = @_;
my @x = split(/\./,$x);
my @y = split(/\./,$y);
while( @x && @y ) {
my $result = shift @x <=> shift @y;
return $result if $result;
}
if( @x ) {
return +1;
}elsif( @y ) {
return -1;
}else{
return 0;
}
}
This is why people try to use multi-level numbers such as 3.02 instead
of 3.2, so they will sort properly as is.
--
Jim Gibson
------------------------------
Date: Fri, 08 Aug 2008 19:20:19 +0000
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: How do I compare strings non-ascii-betically?
Message-Id: <489c9c74$0$851$ba4acef3@news.orange.fr>
Suzanne wrote:
> I am new to Perl but I did a lot of web searching and haven't found an
> answer to my problem.
>
> I have to compare strings that are version numbers. I want to know if
> a version number is less than or equal to another version number.
>
> For example, version 3.2 is less than version 3.16. But when I
> compare them, 3.16 is considered less. I tried the cmp function and
> got the same results.
>
> I could strip the contents after the '.' and compare them numerically
> but it becomes difficult if the version number is 3.2.1.5 (for
> example).
>
> Any ideas? Thanks in advance.
>
Look at the version module, or maybe Perl::Version (I haven't looked at
the latter).
mark@hermes:~$ cat testversion.pl
use strict;
use warnings;
use version;
while(my $line=<DATA>){
chomp $line;
my ($raw1,$raw2) = split /\s+/,$line;
my ($v1,$v2) = map { qv($_) } ($raw1,$raw2);
my $v1greater = $v1 > $v2;
my $equal = $v1 == $v2;
my $v2greater = $v1 < $v2;
printf "v1=%9s v2=%9s v1greater=%d equal=%d v2greater=%d\n",
$v1,$v2,$v1greater,$equal,$v2greater;
}
__DATA__
1.1 1.2
1.1 1.1
1.2 1.1
1.10 1.2
1.1.1 1.1.1
1.1.2 1.1.1
1.1.2 1.1.10
3.2.1.5 3.2.1.4
3.2.1.5 3.2.10.5
3.2.2.5 3.2.1.5
mark@hermes:~$ perl testversion.pl
v1= v1.1 v2= v1.2 v1greater=0 equal=0 v2greater=1
v1= v1.1 v2= v1.1 v1greater=0 equal=1 v2greater=0
v1= v1.2 v2= v1.1 v1greater=1 equal=0 v2greater=0
v1= v1.10 v2= v1.2 v1greater=1 equal=0 v2greater=0
v1= 1.1.1 v2= 1.1.1 v1greater=0 equal=1 v2greater=0
v1= 1.1.2 v2= 1.1.1 v1greater=1 equal=0 v2greater=0
v1= 1.1.2 v2= 1.1.10 v1greater=0 equal=0 v2greater=1
v1= 3.2.1.5 v2= 3.2.1.4 v1greater=1 equal=0 v2greater=0
v1= 3.2.1.5 v2= 3.2.10.5 v1greater=0 equal=0 v2greater=1
v1= 3.2.2.5 v2= 3.2.1.5 v1greater=1 equal=0 v2greater=0
------------------------------
Date: 08 Aug 2008 16:28:35 GMT
From: xhoster@gmail.com
Subject: Re: How to check for filetype existence quickly
Message-Id: <20080808122836.727$Eg@newsreader.com>
Tad J McClellan <tadmc@seesig.invalid> wrote:
> fidokomik <fidokomik@gmail.com> wrote:
> > On Aug 6, 12:02 pm, Lars Eighner <use...@larseighner.com> wrote:
> >> Did you try globbing to see if it is any faster:
Globbing will go through all the files in the directory with no possibility
of stopping early. It won't be more than slightly faster on failure, and
will be substantially slower on success.
> >>
> >> $found = 0;
> >> if (</usr/home/lars/saves/*.cgi>){
> >> $found = 1;
> >>
> >> }
> >>
> > Hmm, easy and quick. Thank you Lars. But how to pass variable to this
> > but avoid eval()? Is it possible?
>
> $extension = 'cgi';
> if (</usr/home/lars/saves/*.$extension>){
>
> Though that would be the bad kind of Lazy, IMO.
>
> It makes it easier for the 1 programmer at the expense of making it
> harder for the many readers/maintainers.
>
> So I would instead write it for others rather than for myself:
>
> if ( glob "/usr/home/lars/saves/*.$extension" ) {
Even this is bad. The glob is being executed in a scalar context,
so doesn't reset itself, it iterates and next time it gets invoked
(assuming the if is in a loop, or a subroutine which gets called from a
loop), the new value of $extension is not even inspected, unless the old
iterator has exhausted itself.
if ( () = glob "/usr/home/lars/saves/*.$extension" ) {
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Fri, 08 Aug 2008 16:49:48 +0200
From: Thomas <th@example.invalid>
Subject: Re: Need help with perlxs and C strings
Message-Id: <g7hmee$cmc$1@aioe.org>
xhoster@gmail.com wrote:
> Yep, I was just exploring that option. In my first attempt I had to copy
> the .h file into the __C__ section. But then I got it to "source" the .h
> directly:
>
> use Inline 'C' => qq{#include "setdata.c"\n} . `cat setdata.h`
> => ENABLE => 'AUTOWRAP';
>
> And it works fine.
I have to interface with compiled C code. I got Inline C to work (ran
the http://search.cpan.org/dist/Inline/C/C-Cookbook.pod#Hello,_world
sample program successfully), but my modified version of runme.pl
doesn't seem to recognize where the compiled object file of setdata.c is
located. I followed the example at
http://search.cpan.org/dist/Inline/C/C-Cookbook.pod#Automatic_Function_Wrappers
and came up with this:
== runme.pl
use Inline C => Config =>
ENABLE => AUTOWRAP =>
LIBS => "-L. -lsetdata";
use Inline C => q{ void set_data(char *); };
my $x="xxxxxxxx";
set_data($x);
print "Data from C function:\n$x";
==
The compiled version of setdata.c (setdata.obj) is placed in the same
directory. However, when running the above script, the linker fails with
this message:
runme_pl_5bec.obj : error LNK2019: unresolved external symbol _set_data
referenced in function _XS_main_set_data
I have to add that I use nmake and cl as compiler and link as linker
under Windows. The information from LIBS never seems to get included (I
only know the -l<lib> syntax from Unix, it may be the problem; I don't
know the alternative). I'd appreciate any further help on how to get
this running.
------------------------------
Date: 08 Aug 2008 16:40:05 GMT
From: xhoster@gmail.com
Subject: Re: Need help with perlxs and C strings
Message-Id: <20080808124007.035$cc@newsreader.com>
Thomas <th@example.invalid> wrote:
> == runme.pl
> use Inline C => Config =>
> ENABLE => AUTOWRAP =>
> LIBS => "-L. -lsetdata";
> use Inline C => q{ void set_data(char *); };
>
...
>
> The compiled version of setdata.c (setdata.obj) is placed in the same
> directory. However, when running the above script, the linker fails with
> this message:
>
> runme_pl_5bec.obj : error LNK2019: unresolved external symbol _set_data
> referenced in function _XS_main_set_data
>
> I have to add that I use nmake and cl as compiler and link as linker
> under Windows.
Unfortunately, I know nothing about building things on Windows.
> The information from LIBS never seems to get included (I
> only know the -l<lib> syntax from Unix, it may be the problem; I don't
> know the alternative). I'd appreciate any further help on how to get
> this running.
Do you know how to link things under your set-up in Windows directly
(i.e. when not using Perl)? You can tell Inline to do a noisy build, where
it will show you every step it is carrying out. If you know what the link
options is supposed to look like in Windows, maybe you can use the
information from the noisy build to figure how to tweak the options to make
that happen.
Also, is the "cl" compiler the compiler which perl itself was compiled
on? If not, you might run in problems no matter what.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Fri, 08 Aug 2008 11:36:05 GMT
From: Peter Scott <Peter@PSDT.com>
Subject: Re: OO Perl
Message-Id: <pan.2008.08.08.11.36.04.998707@PSDT.com>
On Thu, 07 Aug 2008 17:49:36 -0700, Matt wrote:
> I'm curious to see if people are
> opting to use a language like Ruby with Rails over using Perl....since
> Perl's OOness is a bit...forced.
You...noticed.
> Just wondering. Also, over the years I've developed sort of my own
> Perl OO style, if anyone is interested in using some of the Perl OO
> helper methods I've developed (or reviewing/critiquing )....let me
> know.
Sure, provided you first check on what has already been done in this area,
because OO helper modules/style/methods have been done practically to
death and your chances of reinventing a wheel are high, If you don't know
what Moose is, start there.
--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/
------------------------------
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 1780
***************************************