[24532] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 6712 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 21 03:06:22 2004

Date: Mon, 21 Jun 2004 00:05:05 -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           Mon, 21 Jun 2004     Volume: 10 Number: 6712

Today's topics:
    Re: (?{..}) and lexical scoping issues. <sourceror@front.ru>
    Re: Creating a scalar value from other scalars (Alan Curry)
    Re: Creating a scalar value from other scalars <usenet@morrow.me.uk>
    Re: Embedding perl in Java (Shalini Joshi)
    Re: Help: Delete a single carriage return in a file, bu <steveo@member.fsf.org>
        HTTP::Proxy::BodyFilter::Adnix 0.01 released on CPAN <cosimo@cpan.org>
    Re: KeepCDATA => 1 in XML::DOM <mgjv@tradingpost.com.au>
        Perl DNS reverse lookups -- multiple IP addresses per l (Maynard)
    Re: Perl DNS reverse lookups -- multiple IP addresses p (Sam Holden)
        Platform-independent way of passing cmd-line args. (Prabh)
    Re: Platform-independent way of passing cmd-line args. <usenet@morrow.me.uk>
    Re: Platform-independent way of passing cmd-line args. <invalid-email@rochester.rr.com>
        SQL Error <ales_1969@yahoo.com>
    Re: WMI and boolean values from Win32_Processor (Daniel Berger)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 21 Jun 2004 03:55:14 +0400
From: "Aronaxis, the Sourceror" <sourceror@front.ru>
Subject: Re: (?{..}) and lexical scoping issues.
Message-Id: <opr9w3ecimla67zl@s>

On 20 Jun 2004 17:10:56 GMT, Anno Siegel  
<anno4000@lublin.zrz.tu-berlin.de> wrote:

> Aronaxis, the Sourceror <sourceror@front.ru> wrote in  
> comp.lang.perl.misc:
>> # ind_compare($string1,$string2 [,accuracy] )
>> #            calculates strings "similarity"
>> # algorithm is cutted from some old Pascal code, and rewritten to use
>> # perl RE-engine backtracking for speed.
>>
>> use warnings;
>> use strict;
>>
>> sub DEBUG () {1}
>>
>> our ($cnt, $match);
#inserted:
    our $i;
>> sub ind_compare ($$;$) {
>> 	my $max_len = $_[2];
>>
>> 	# numification for security reasons.
>> 	$max_len="" unless $max_len +=0;
>> 	
>> 	# WHY NOT?!
>> 	# my ($cnt,$match)=(0,0);
>> 	($cnt, $match) = (0,0);
>>
>>          use re 'eval'; # because of $max_len interpolation
>>                         # in regex below. But we cleaned it.
>>
>> 	# loop for comparing $_[0] against $_[1], and $_[1] against $_[0] too
>> 	for my $i (0,1) {
#changed:
       for    $i (0,1) {
>> 	  $_[$i] =~  m{
>> 	       ( .{1,$max_len} )
>> 	       (?{
>> 	       	  $cnt++;
>> 	       	  $match++ if index( $_[1-$i], $1 ) != -1;
>> 	       })
>> 	       (?!)   # that always fail and force backtracking.
>> 	     }x;
>> 	 }
>>
>> 	 print "$match/$cnt\n" if DEBUG;	
>> 	
>> 	 return 0 unless $cnt;
>> 	 $match/$cnt;
>> }
>>
>>
>> print ind_compare( "abcdefgh","abcdefgh" ), "\n\n";
>> print ind_compare( "abcdefg!","abcdefgh" ), "\n\n";
>>
>>

{...}

> I don't have a pat explanation, except to point out that "(?{ ... })"
> is still experimental.  It has had scoping issues from day one and
> still has.
>
>> looks like some scoping issues, but then why there are no problems with
>> lexical scoped $i, or @_ (which AFAIK is also lexical) ?
>
> @_ is most definitely a package variable.

hm.. I'm sure I've read something claiming that @_ in perl5 behave more as  
lexical than as package.. but I think you're right. And it's too hard to  
feel the difference in this case... I think, if that function will make a  
reference to @_ and store it somewhere, it would break next invocation the  
same way as described. Looks like function internal variables tend to use  
the same "addresses" on next invocation, if only they can..
("hm.."x2; I tested it now :). \@_ remains the same on several  
invocations, but when I pushed \@_ to package array @temp, forcing perl to  
change the \@_ on next invocation, regex still works correcly, as before..)

> The distinction is not with lexical vs. local.  If you change "our" to
> "my", but keep the declarations out of the sub, you'll see the same
> difference.

I tested this too. for ($cnt,$match) it's correct. for $i - no. It should  
be "our". I think that's because perl's "for" behaves slightly different  
based on how variable with same name as "for"'s ..er.. iterator declared  
in outer scope: as package or as lexical. Package var will be localized in  
loop, but if there is lexical $i in scope, then "for $i (...)" works as  
"for my $i (...)" does. It's only my assumption.. am I right?

> I also believe you are mistaken about there being no problems with $i.
> In fact, its behavior can also be described as it having a different
> value inside the regex and outside.  This means that in effect you are
> doing "index( $_[1], $1)" both times through the loop, though the regex
> is first matched against $_[0] and then against $_[1].

yeah, thank you. I used badly chosen tests and didn't notice a difference.

> Check this by removing "my" in front of "$i" and adding "$i" to the list
> of "our" variables outside the loop.  You will find that the match count
> changes from 64 to 56 in the second case, which, I think, is correct.
> (You are counting how many substrings of each string are also substrings
> of the other, right?)

right.

> On a more general note, why are you doing this?  As far as I can see,
> there is no advantage in using the regex backtracking mechanism and
> (?{ ... }) against a more conventional method of calling Perl code.
> What you are really using it for is a mechanism to walk through
> all substrings of a string.  That's somewhat neat, but not necessarily
> a speed gain.  If the original Pascal program is anything like I imagine
> it to be, it will be hard to beat with a Perl program.

actually, it was my rewrite of another perl program, which made by my  
friend from pascal program using "one-to-one" translation. It involved  
many length(), substr(), eq, and nested loops, but he didn't ever used  
index().
he send me his code and some another variants on other languages with  
comparison chart:

Perl - 17.50s
O'Caml raw bytecode - 9.77s
O'Caml funcional bytecode - 9.55s
O'Caml funcional native - 1.68s
O'Caml raw native - 1.63s

his perl program was too lowlevel, and as my experience tells me,  
"lowlevel" in perl's case means "slow". and ugly too. And I wonder if I  
can use internal regex loop for memory saving (I didn't know how long are  
lines he used to compare) and speed.. btw, I never used (?{}) before and  
was curious. So you've seen what curiosity made to fox.

BTW, my rewrite took only 5.2s on former test.


> To do it in Perl, I wouldn't employ the regex engine at all.  Instead
> I'd base it on a procedure to extract all non-empty substrings from
> a string.  Ignoring the requirement for a maximal string length for
> simplicity, something like this would do:
>
>     use constant DEBUG => 1;
>
>     print ind_compare( "abcdefgh","abcdefgh" ), "\n\n";
>     print ind_compare( "abcdefg!","abcdefgh" ), "\n\n";
>
>     sub ind_compare {
>         my ( $s, $t) = @_;
>         my ( $count, $match);
>         for ( 1, 2 ) {
>             my @sub = all_substr( $s);
>             $count += @sub;
>             $match += grep 1 + index( $t, $_), @sub;
>             ( $s, $t) = ( $t, $s);
>         }
>
>         print "$match/$count\n" if DEBUG;
>         $count ? $match/$count : 0;
>     }
>
>     sub all_substr {
>         my $s = shift;
>         my @sub;
>         while ( length $s ) {
>             push @sub, map substr( $s, $_), 0 .. length( $s) - 1;
>             chop $s;
>         }
>         @sub;
>     }
>
> Anno

Thank you, it was real pleasure to read such a code.. it's perfect.
only one drawback I can see - it generates list of all possible substrings  
before checking it, which can take too much memory on arbitrarily long  
strings.. but I'm in doubt if this function would be useful on long  
strings comparison. so your version is great.

   Alexey


------------------------------

Date: 21 Jun 2004 00:25:26 GMT
From: pacman@manson.clss.net (Alan Curry)
Subject: Re: Creating a scalar value from other scalars
Message-Id: <cb59tm02uod@enews3.newsguy.com>

In article <gplBc.832453$Ig.490304@pd7tw2no>,
Robert TV <ducott@hotmail.com> wrote:
>$ipaddress =~ s/\.//g; #remove periods from IP address
>$filename = "$ipaddress\_$timestamp\.dat";

Why remove the dots? If you're interested in IP addresses, you probably don't
want to treat 12.122.11.50 (gbr1-p40.cgcil.ip.att.net) and 12.12.211.50
(50.juneau-05rs16rt.ak.dial-access.att.net) as identical.

Dots in filenames are not normally a problem. If they're a problem for you,
replace them with underscores, convert the whole IP address into a single
number like this:

use Socket;
my $longipaddress = unpack "N", inet_aton($ipaddress);
# Or even this:
my $hexipaddress = sprintf "%08x", unpack "N", inet_aton($ipaddress);

-- 
Alan Curry
pacman@clss.net


------------------------------

Date: Mon, 21 Jun 2004 00:56:19 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Creating a scalar value from other scalars
Message-Id: <cb5bnj$o9j$2@wisteria.csv.warwick.ac.uk>


Quoth pacman@manson.clss.net (Alan Curry):
> In article <gplBc.832453$Ig.490304@pd7tw2no>,
> Robert TV <ducott@hotmail.com> wrote:
> >$ipaddress =~ s/\.//g; #remove periods from IP address
> >$filename = "$ipaddress\_$timestamp\.dat";
> 
> Why remove the dots? If you're interested in IP addresses, you probably don't
> want to treat 12.122.11.50 (gbr1-p40.cgcil.ip.att.net) and 12.12.211.50
> (50.juneau-05rs16rt.ak.dial-access.att.net) as identical.

You should also note that this value will not uniquely identify a given
request: it is perfectly possible for many requests to arrive from the
same ip in a second, especially if it is a NAT box with several hosts
behind it.

Ben

-- 
"If a book is worth reading when you are six,                * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis


------------------------------

Date: 20 Jun 2004 23:00:25 -0700
From: shalinij1@yahoo.com (Shalini Joshi)
Subject: Re: Embedding perl in Java
Message-Id: <283d6b7e.0406202200.291e16d2@posting.google.com>

Hey!

Yeah Ben, thanks again..i managed to use perlcc to produce an
executable on the unix system. It didnt work on windows though(like it
had been pointed out in the doc)so used the B module to produce the
bytecode.

Yeah will let my boss know about the source code hiding issues..thanks
again.

--Shalini


Ben Morrow <usenet@morrow.me.uk> wrote in message news:<cb4p8t$h7d$1@wisteria.csv.warwick.ac.uk>...
> Quoth shalinij1@yahoo.com (Shalini Joshi):
> > Ben Morrow <usenet@morrow.me.uk> wrote in message 
> > > 
> > > For advice on (the futility of) concealing Perl code in general, see
> > > perldoc -q hide.
> > 
> > Thanks a lot Ben for this information. All this while we were really
> > feeling smart thinking we could actually solve the problem of hiding
> > the source by embedding perl in java. Is there a solution to this
> > problem? Do u mean to say that no commercial product makes use of Perl
> > as a source language??
> 
> Have you read that faq? There are a variety of solutions, none of them
> secure. It doesn't matter, though, as source code hiding never works
> anyway and all you need to do is slap a big fat copyright notice on it
> and noone can steal it.
> 
> You would need to talk to your company lawyers, of course.
> 
> Ben


------------------------------

Date: Mon, 21 Jun 2004 00:48:21 GMT
From: Steve Anderson <steveo@member.fsf.org>
Subject: Re: Help: Delete a single carriage return in a file, but not a double carriage return?
Message-Id: <pan.2004.06.21.00.59.37.356925@member.fsf.org>

On Sun, 20 Jun 2004 12:29:20 +0000, Anno Siegel wrote:

> You say "remove", but from your example you want to replace isolated
> line feeds with blanks.

You're absolutely right, my text was wrong, my example was right.  Thanks
for seeing through it, and thanks for the solution.

     Steve


------------------------------

Date: Sat, 19 Jun 2004 11:33:49 GMT
From: Cosimo Streppone <cosimo@cpan.org>
Subject: HTTP::Proxy::BodyFilter::Adnix 0.01 released on CPAN
Message-Id: <HzMp2D.B3z@zorch.sf-bay.org>

HTTP/Proxy/BodyFilter/Adnix version 0.01
========================================

This class implements a HTTP::Proxy body filter which blocks images
based on some rules you specify (or built-in default rules), and
replaces it with custom image you specify (or again, a built-in one).

You won't be able to do anything useful with this software
unless you install HTTP::Proxy and all its components.

This is not meant as a "Can't live without it" module, but rather
as a first simple example that builds up a BodyFilter class for
HTTP::Proxy distribution that is also useful for my personal
pure-perl proxying needs.

It is my intention to release on CPAN also a proxy daemon based
on HTTP::Proxy, just to have an all-in-one package, ready to
install and out-of-the-box. May be useless??? Who knows?


DEPENDENCIES

- HTTP::Proxy (at least version 0.12 I think)


INSTALLATION

To install this module type the following:

    perl Makefile.PL
    make
    make test
    make install


COPYRIGHT AND LICENCE

Copyright (C) 2004 Cosimo Streppone <cosimo at cpan dot org>

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.




------------------------------

Date: Mon, 21 Jun 2004 10:38:51 +1000
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: KeepCDATA => 1 in XML::DOM
Message-Id: <slrncdcbgr.mlm.mgjv@martien.heliotrope.home>

On Sun, 20 Jun 2004 19:07:44 +0200,
	Markus Mohr <markus.mohr@mazimoi.de> wrote:
> On 17 Jun 2004 23:01:25 GMT, Martien Verbruggen
><mgjv@tradingpost.com.au> wrote:
> 
>>[Please, do not post the same message to two newsgroups independently.
>>You also posted this to comp.lang.perl.modules. Instead, use your
>>newsreader's crossposting facility to post to multiple groups]
>>
>>On Thu, 17 Jun 2004 22:47:38 +0200,
>>	Markus Mohr <markus.mohr@mazimoi.de> wrote:
>>> Hi, all,
>>> 
>>> is it possible that "KeepCDATA => 1" within XML::DOM (e. g. 1.43) does
>>> not work properly?
>>
>>It is possible, although I'd rate it as unlikely. What makes you think
>>it doesn't work? Where is the code that you tested, and where is the
>>data you tested it with? If you post a small self-contained code
>>example and XML document here, we can have a look at it for you.
> 
> Have sent them privately due to attachment limitations.

I won't be seeing them, as I am starting a holiday of four weeks today,
and I'm not going to be accesing my work mailbox.

Just for the record: I wasn't offering to be a personal helpdesk for
this. I was trying to subtly indicate to you that you should post some
code and data when you ask a question. Read the posting guidelines that
regularly get submitted here.

Since both Perl and XML are text, make them part of the body of the
post. Do not post attachments. If it's too large to include, put them on
a HTTP or FTP server somewhere, and post the URL.

Don't ever assume that you can mail stuff directly to people, unless
_specifically_ stated, i.e. with first person singular.

Martien
-- 
                        | 
Martien Verbruggen      | The Second Law of Thermodenial: In any closed
                        | mind the quantity of ignorance remains
                        | constant or increases.


------------------------------

Date: 20 Jun 2004 22:33:56 -0700
From: rev_maynard3@hotmail.com (Maynard)
Subject: Perl DNS reverse lookups -- multiple IP addresses per line
Message-Id: <a4847dc.0406202133.7bd4a5fe@posting.google.com>

Hello all,

I'm attempting to take a log file with several thousand IP addresses
and convert them into their DNS named equivalent -- Not so hard.  But
what's stumping me is some basic regex syntax.  I know that the 'g'
operator should allow me to continue from where I left off, but I seem
to be missing the correct way to implement this... my script is
picking up the first IP address in the line, but not the second. 
Perhaps someone can show me the error of my ways and get me back on
track.

Input log file is formatted like this:

TCP out 65.198.222.70:43679 in 192.168.0.3:80 idle 0:00:08
TCP out 209.73.24.2:29042 in 192.168.0.3:80 idle 0:00:08
TCP out 65.198.222.70:43685 in 192.168.0.3:80 idle 0:00:00
 ...


Complete script:
----------------------------------

use Socket;

my ($ip, $hostname);
my ($SourceFile, $DestFile) = ("log1.txt", "log2.txt");

open(INPUTFILE, "<$SourceFile") || die("ERROR: Cannot open
$SourceFile, $!");
open(OUTPUTFILE, ">$DestFile") || die("ERROR: Cannot open $DestFile,
$!");

binmode INPUTFILE;
binmode OUTPUTFILE;

while(<INPUTFILE>) {
	my $line = $_;
	
	if ($line =~ /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/g) {

		$ip = $1;
		$hostname = lc gethostbyaddr(inet_aton($ip),AF_INET);

		if ($hostname ne "") {
			$line =~ s/$g_ip/$g_hostname/;
			print " IP address $ip = $hostname\n";
		}
		else {
			print " IP address $ip = *NO DNS RECORD FOUND*\n";
		}
	}
	
	print OUTPUTFILE $line;
}

close(INPUTFILE);
close(OUTPUTFILE);

----------------------------------


Thanks very much for any help.


------------------------------

Date: 21 Jun 2004 06:45:17 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl DNS reverse lookups -- multiple IP addresses per line
Message-Id: <slrncdd0vt.dgq.sholden@flexal.cs.usyd.edu.au>

On 20 Jun 2004 22:33:56 -0700, Maynard <rev_maynard3@hotmail.com> wrote:
> Hello all,
> 
> I'm attempting to take a log file with several thousand IP addresses
> and convert them into their DNS named equivalent -- Not so hard.  But
> what's stumping me is some basic regex syntax.  I know that the 'g'
> operator should allow me to continue from where I left off, but I seem
> to be missing the correct way to implement this... my script is
> picking up the first IP address in the line, but not the second. 
> Perhaps someone can show me the error of my ways and get me back on
> track.
> 
> Input log file is formatted like this:
> 
> TCP out 65.198.222.70:43679 in 192.168.0.3:80 idle 0:00:08
> TCP out 209.73.24.2:29042 in 192.168.0.3:80 idle 0:00:08
> TCP out 65.198.222.70:43685 in 192.168.0.3:80 idle 0:00:00
> ...
> 
> 
> Complete script:
> ----------------------------------
> 
> use Socket;
> 
> my ($ip, $hostname);
> my ($SourceFile, $DestFile) = ("log1.txt", "log2.txt");
> 
> open(INPUTFILE, "<$SourceFile") || die("ERROR: Cannot open
> $SourceFile, $!");
> open(OUTPUTFILE, ">$DestFile") || die("ERROR: Cannot open $DestFile,
> $!");
> 
> binmode INPUTFILE;
> binmode OUTPUTFILE;
> 
> while(<INPUTFILE>) {
> 	my $line = $_;
> 	
> 	if ($line =~ /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/g) {

You need to loop for the g to have any effect. so s/if/while/.

However, you do a s// on $line inside the body - I don't know if that will
break the /g pickup point or not. Read the documentation and check I guess.

Or you could do something like:

while (<INPUTFILE>) {
    s/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
        lc gethostbyaddr(inet_aton($1),AF_INET)||$1/ge;
    print OUTPUTFILE;
}

-- 
Sam Holden


------------------------------

Date: 20 Jun 2004 17:40:38 -0700
From: Prab_kar@hotmail.com (Prabh)
Subject: Platform-independent way of passing cmd-line args.
Message-Id: <e7774537.0406201640.14f2ecce@posting.google.com>

Hello all,
I need to pass a couple of args to my perl script which are strings of
text.
Arg1: 'one two'
Arg2: 'three four'

Script:
====================================================
#!/usr/local/bin/perl

use strict ;
use warnings ;

my $first_arg = $ARGV[0] ;
my $sec_arg   = $ARGV[1] ;

print "First: $first_arg\nSecond: $sec_arg\n" ;
====================================================


On Unix, when I pass the args as,
       <%> perl testArgs.pl  'one two' 'three four'
I get the output,
    First: one two
    Second: three four

When I try the same script and pass the args in the same way on
Windows, I get,
First: 'one
Second: two'

Its only when I replace the single-quote on the command-line with
double-quotes do I get the same results as Unix.
       <%> perl  testArgs.pl  "one two" "three four"

Is there any platform independent way of passing args which result in
the same
ARGV[0] and ARGV[1] on all platforms?

Perl version:  perl v5.6.0

Thanks for your time,
Prabh


------------------------------

Date: Mon, 21 Jun 2004 00:53:22 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Platform-independent way of passing cmd-line args.
Message-Id: <cb5bi2$o9j$1@wisteria.csv.warwick.ac.uk>


Quoth Prab_kar@hotmail.com (Prabh):
> 
> On Unix, when I pass the args as,
>        <%> perl testArgs.pl  'one two' 'three four'
> I get the output,
>     First: one two
>     Second: three four
> 
> When I try the same script and pass the args in the same way on
> Windows, I get,
> First: 'one
> Second: two'
> 
> Its only when I replace the single-quote on the command-line with
> double-quotes do I get the same results as Unix.
>        <%> perl  testArgs.pl  "one two" "three four"
> 
> Is there any platform independent way of passing args which result in
> the same
> ARGV[0] and ARGV[1] on all platforms?

This is not a Perl question: it is a matter of your command shell. If
you use a Unix-ish shell under win32 (cygwin bash, or there is a native
port of zsh available) then single-quotes will work fine.

In general double-quotes are pretty portable, provided you don't need
$, `, \, " or % in the arguments (unix shells will interpret the first
four, DOS/cmd.exe the last two).

Ben

-- 
  Joy and Woe are woven fine,
  A Clothing for the Soul divine       William Blake
  Under every grief and pine          'Auguries of Innocence'
  Runs a joy with silken twine.                                ben@morrow.me.uk


------------------------------

Date: Mon, 21 Jun 2004 00:55:32 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Platform-independent way of passing cmd-line args.
Message-Id: <40D631EA.4010201@rochester.rr.com>

Prabh wrote:

 ...
> Is there any platform independent way of passing args which result in
> the same
> ARGV[0] and ARGV[1] on all platforms?


No.  Command line argument quoting is a function of the particular 
"shell" running on a particular operating system.  You only asked about 
*nix and Windoze -- on Windoze, you could run Perl under Cygwin, which, 
if you use its default bash shell (and, probably, any of the other 
shells it provides), will let you quote arguments with ' characters like 
*nix.  But it will be running on Windoze.

HTH.


 ...


> Prabh

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



------------------------------

Date: Mon, 21 Jun 2004 08:12:32 +0200
From: Alex <ales_1969@yahoo.com>
Subject: SQL Error
Message-Id: <MPG.1b409aa79b2a9200989680@news.siol.net>

Hi !

I am using MySQL database for a 3-4 years using the same Perl scripts.
Till 6 months ago I had approx. 500k record updates/day with no problem.
After that, I made some statistical enging, which does few million 
records per day. (Changed configuration to huge.cnf also).

Now, from time to time, database connect fails and the error is

Can't connect to local MySQL server through socket 
'/var/lib/mysql/mysql.sock' (2)

There is no problem with the file & permissions etc.. 

Could this be some performance problem rather than DBI & OS related ?

Thx


------------------------------

Date: 20 Jun 2004 16:20:30 -0700
From: djberg96@hotmail.com (Daniel Berger)
Subject: Re: WMI and boolean values from Win32_Processor
Message-Id: <6e613a32.0406201520.2e4c618f@posting.google.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<cb4je2$rf0$1@mamenchi.zrz.TU-Berlin.DE>...
> Daniel Berger <djberg96@hotmail.com> wrote in comp.lang.perl.misc:
> > Hi all,
> > 
> > A.S. Perl 5.8.1
> > Windows 2000
> > 
> > I noticed that when using Win32::OLE + WMI, the boolean return values
> > from the Win32_Processor class return undef instead of a value.
> 
> What makes you think the return values are undefined?

When I 'use warnings', I know for sure. :)  It is definitely
undefined.

<snip>

> > The ConfigManagerErrorCode and ErrorCleared attributes (among others)
> > are of type boolean.  I would expect a 0 or 1 for these attributes,
> > not undef.  Or is it understood that undef == false?  Or is a WMI
> > issue?  I didn't see anything in the Win32::OLE docs that specifically
> > mentioned this.
> 
> It is standard Perl practice to return 1 for boolean true, but an
> empty string[1] for false.  It is still a defined value.  So your
> result is consistent with normal behavior.  I suppose that is the
> case.

As I mentioned, it's definitely undefined.  In fact, I made a mistake
with my sample code.  The 'ConfigManagerErrorCode' is an integer in
the range 0 to 31 but it, too, is coming back undefined.  I tried the
same code on my WinXP Home laptop, but they were also undefined.

So, either they're only defined in XP Pro and later or there's a bug
in WMI (or just the WMI documentation).  That, or Win32::OLE is broken
somehow.  If that's the case, it's broken in the same way in Ruby's
win32ole package (which I also tested with).

Anyway, thanks for the tip.

Regards,

Dan


------------------------------

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 6712
***************************************


home help back first fref pref prev next nref lref last post