[25672] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7913 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 29 12:47:09 2005

Date: Tue, 29 Mar 2005 09:47:01 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 29 Mar 2005     Volume: 10 Number: 7913

Today's topics:
        How to configure baud etc on Linux? <taffy94@hotmail.com>
    Re: How to configure baud etc on Linux? <Juha.Laiho@iki.fi>
        how to get installed program path under Windows like Wi <Liwei.Yao@gmail.com>
    Re: how to get installed program path under Windows lik <see.sig@rochester.rr.com>
    Re: how to get installed program path under Windows lik <Liwei.Yao@gmail.com>
    Re: how to get installed program path under Windows lik <1usa@llenroc.ude.invalid>
    Re: how to get installed program path under Windows lik <pilkowsk@informatik.uni-marburg.de>
        if statement oddity <jens.luedicke@gmail.com>
    Re: if statement oddity <felix.geerinckx@gmail.com>
    Re: if statement oddity <noreply@gunnar.cc>
    Re: if statement oddity <jens.luedicke@gmail.com>
    Re: if statement oddity <mritty@gmail.com>
    Re: if statement oddity <felix.geerinckx@gmail.com>
    Re: if statement oddity <jens.luedicke@gmail.com>
    Re: if statement oddity <nobull@mail.com>
    Re: if statement oddity <tadmc@augustmail.com>
    Re: if statement oddity <noreply@gunnar.cc>
    Re: if statement oddity <noreply@gunnar.cc>
    Re: if statement oddity <nobull@mail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 26 Mar 2005 17:24:56 +0000
From: "Martin Doyle" <taffy94@hotmail.com>
Subject: How to configure baud etc on Linux?
Message-Id: <pan.2005.03.26.17.24.56.149440@hotmail.com>

I want to write a perl script to read text data (alarms) recieved on the 
serial port and write this into a database. 

Apart from configuring the serial port I know where I'm going with this,
do I need to use Net::DeviceSerialport? This seems like overkill, or is
there another way?

Thanks

Martin


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

Date: Fri, 25 Mar 2005 17:59:49 +0000 (UTC)
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: How to configure baud etc on Linux?
Message-Id: <d21jil$eee$2@ichaos.ichaos-int>

"Martin Doyle" <taffy94@hotmail.com> said:
>I want to write a perl script to read text data (alarms) recieved on the 
>serial port and write this into a database. 
>
>Apart from configuring the serial port I know where I'm going with this,
>do I need to use Net::DeviceSerialport? This seems like overkill, or is
>there another way?

In C you'd do this with 'termios' system calls (cfsetospeed); have a look
whether perl provides a wrapper around this function.
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


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

Date: 27 Mar 2005 06:14:21 -0800
From: "Lance" <Liwei.Yao@gmail.com>
Subject: how to get installed program path under Windows like Win32 API?
Message-Id: <1111932861.136312.194840@o13g2000cwo.googlegroups.com>

how to get installed program name/path pair under winXP like Win32 API
does?

Though I do know it's not so conform to this group's posting law for
such a brief description which is absent of exact input and expected
output. However I can't describe my question in that detail. Sorry for
that.

Any solution or hint is appreciated very much.



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

Date: Sun, 27 Mar 2005 18:34:22 GMT
From: Bob Walton <see.sig@rochester.rr.com>
Subject: Re: how to get installed program path under Windows like Win32 API?
Message-Id: <O0D1e.121272$H05.98457@twister.nyroc.rr.com>

Lance wrote:

> how to get installed program name/path pair under winXP like Win32 API
> does?

Not sure what the question is supposed to be.  Does the $^X 
variable answer it (see perldoc perlvar)?  That returns the 
path/filename of the Perl executable which is running the script.
 ...
-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl


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

Date: 28 Mar 2005 05:39:10 -0800
From: "Lance" <Liwei.Yao@gmail.com>
Subject: Re: how to get installed program path under Windows like Win32 API?
Message-Id: <1112017150.196020.209710@f14g2000cwb.googlegroups.com>

Hi Bob, thanks for your reply.

Nevertheless there's a little bit misunderstanding for you. The
installed program I mean here is not the path of perl.exe, but other
installed programs, such notepad.exe, msword.exe, photoshop.exe etc.

What I want here is the method to get out the path from the likely
execution file name. For example, if the Microsoft word is installed at
C:\wordXP\, whose execution file is msword.exe under C:\wordXP\. The
program input is the likely name of the execution file, such word,
msword etc. the expected out is the execution file path
c:\wordXP\msword.exe.

Is my current description detail enough? :) Any information is welcome.



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

Date: Mon, 28 Mar 2005 13:50:46 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: how to get installed program path under Windows like Win32 API?
Message-Id: <Xns962759FEF64A0asu1cornelledu@127.0.0.1>

"Lance" <Liwei.Yao@gmail.com> wrote in
news:1112017150.196020.209710@f14g2000cwb.googlegroups.com: 

> Hi Bob, thanks for your reply.

[ Please quote an appropriate amount of context ]
 
> Nevertheless there's a little bit misunderstanding for you.

I don't think he misunderstood, rather you have failed to explain.

> The installed program I mean here is not the path of perl.exe, but
> other installed programs, such notepad.exe, msword.exe, photoshop.exe
> etc. 

In your original message, you mention the Win32 API. Maybe, if you told
us which Win32 API function does what you want, we might be able to
figure out exactly what you are looking for. 

> What I want here is the method to get out the path from the likely
> execution file name.

How do you figure out what the "likely execution file name" is?

> For example, if the Microsoft word is installed at
> C:\wordXP\, whose execution file is msword.exe under C:\wordXP\. The
> program input is the likely name of the execution file, such word,
> msword etc. the expected out is the execution file path
> c:\wordXP\msword.exe.

sub msword_path { 'C:/wordXP/msword.exe' }

> Is my current description detail enough? :) 

No.

For the example above you describe, what arguments whould you call the
function with, and expect to get the full path of the main executable of
the installed package? 

Sinan.


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

Date: Tue, 29 Mar 2005 01:44:19 +0200
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: how to get installed program path under Windows like Win32 API?
Message-Id: <3arj64F6cumk0U1@individual.net>

* Lance schrieb:
> 
> Nevertheless there's a little bit misunderstanding for you. The
> installed program I mean here is not the path of perl.exe, but other
> installed programs, such notepad.exe, msword.exe, photoshop.exe etc.
> 
> What I want here is the method to get out the path from the likely
> execution file name. For example, if the Microsoft word is installed at
> C:\wordXP\, whose execution file is msword.exe under C:\wordXP\. The
> program input is the likely name of the execution file, such word,
> msword etc. the expected out is the execution file path
> c:\wordXP\msword.exe.

Sometimes I'd installed a new update for a program, I'd got a popup that
told me Windows is searching for the current path of this program.
Usually this takes up several minutes until the path is found. Therefore
I think you have to look into all possible paths if you really want to
do this for any executable you have on your disk.

But sometimes programs add an entry into the registry where anyone can
look up to get this information. But these entries are program-specific
and there is AFAIK no standardized location for.

So I'll suggest you scan all your program and system directories to find
your corresponding executable. Have a look at File::Find for doing this
comfortably.

regards,
fabian


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

Date: Fri, 25 Mar 2005 19:43:17 +0100
From: Jens Luedicke <jens.luedicke@gmail.com>
Subject: if statement oddity
Message-Id: <42445bc8$0$27184$9b4e6d93@newsread4.arcor-online.net>

Hiya..

I encountered a strange problem with an if () statement:

if ((my $r = &{$self->{onFile}}($path) != SUCCESS)) {
	return $r;
}

The above code seems to ignore the return value of the function
and somehow overrides it. the return value of the called function
returns FAILED, but $r doesn't reflect that!?

The following code, works as expected:

my $r = &{$self->{onFile}}($path);

if ($r != SUCCESS)) {
	return $r;
}

fyi, SUCCESS is a constant. use constant SUCCESS => 1;

both code examples should work the same. no matter what!?

do I miss something? I'm a little disturbed right now.


jens

-- 
Jens Luedicke
web: http://perldude.de


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

Date: Fri, 25 Mar 2005 19:06:18 GMT
From: "Felix Geerinckx" <felix.geerinckx@gmail.com>
Subject: Re: if statement oddity
Message-Id: <xn0e06jly1wqmk000@news.easynews.com>

On 25/03/2005, Jens Luedicke wrote:

> if ((my $r = &{$self->{onFile}}($path) != SUCCESS)) {
> 	return $r;
> }

[...]
 
> my $r = &{$self->{onFile}}($path);
> 
> if ($r != SUCCESS)) {
> 	return $r;
> }

[...]
 
> both code examples should work the same. no matter what!?
> do I miss something? I'm a little disturbed right now.


Look up the operator precedence rules at the top of 

	perldoc perlop

(!= is evaluated before =)

-- 
felix


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

Date: Fri, 25 Mar 2005 19:53:58 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: if statement oddity
Message-Id: <3aj5q3F67p293U1@individual.net>

Jens Luedicke wrote:
> I encountered a strange problem with an if () statement:
> 
> if ((my $r = &{$self->{onFile}}($path) != SUCCESS)) {
>     return $r;
> }
> 
> The above code seems to ignore the return value of the function
> and somehow overrides it. the return value of the called function
> returns FAILED, but $r doesn't reflect that!?

How about enabling warnings? Using the string 'FAILED' in a numerical 
comparison isn't very wise.

But the behaviour is about precedence. The return value of the function 
is compared with the SUCCESS constant, and $r is assigned the bolean 
value resulting from that comparison. This should do what you want:

     if ( ( my $r = &{$self->{onFile}}($path) ) ne SUCCESS ) {
         return $r;
     }

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Fri, 25 Mar 2005 20:17:36 +0100
From: Jens Luedicke <jens.luedicke@gmail.com>
Subject: Re: if statement oddity
Message-Id: <424463ce$0$27203$9b4e6d93@newsread4.arcor-online.net>

Gunnar Hjalmarsson wrote:

> How about enabling warnings? Using the string 'FAILED' in a numerical 
> comparison isn't very wise.

I use warnings.

FAILED and SUCCESS are numerical constants.

the specific code is on the Filer/DirWalk.pm module of my Filer program.

> But the behaviour is about precedence. The return value of the function 
> is compared with the SUCCESS constant, and $r is assigned the bolean 
> value resulting from that comparison. This should do what you want:
> 
>     if ( ( my $r = &{$self->{onFile}}($path) ) ne SUCCESS ) {
>         return $r;
>     }
> 

using 'ne' doesn't make a difference and wouldn't be practical in a 
numerical comparison.

to avoid problems with precedence the assignment is enclosed in 
parentheses. so the assignment should hbe evaluated first and its return 
value compared afterwards. At least that's what I expect.


-- 
Jens Luedicke
web: http://perldude.de


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

Date: Fri, 25 Mar 2005 19:23:20 GMT
From: Paul Lalli <mritty@gmail.com>
Subject: Re: if statement oddity
Message-Id: <IyZ0e.17882$jt6.14560@trndny07>

Jens Luedicke originally wrote:
 > Hiya..
 >
 > I encountered a strange problem with an if () statement:
 >
 > if ((my $r = &{$self->{onFile}}($path) != SUCCESS)) {
 >     return $r;
 > }
 >

Jens Luedicke then later wrote:
> to avoid problems with precedence the assignment is enclosed in 
> parentheses. so the assignment should hbe evaluated first and its return 
> value compared afterwards. At least that's what I expect.


Exactly where in your code are you using parentheses around the 
assignment?  You're enclosing the entire if statement in parentheses, 
not any particular part of it.

Paul Lalli


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

Date: Fri, 25 Mar 2005 19:27:55 GMT
From: "Felix Geerinckx" <felix.geerinckx@gmail.com>
Subject: Re: if statement oddity
Message-Id: <xn0e06k542ojk0001@news.easynews.com>

On 25/03/2005, Jens Luedicke wrote:

> to avoid problems with precedence the assignment is enclosed in
> parentheses. so the assignment should hbe evaluated first and its
> return value compared afterwards. At least that's what I expect.

Look at your code (copied from your original post for reference):

> if ((my $r = &{$self->{onFile}}($path) != SUCCESS)) {
>	return $r;
> }

The assignment isn't enclosed in parentheses. The full statement is
enclosed in double parentheses.

-- 
felix


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

Date: Fri, 25 Mar 2005 20:33:03 +0100
From: Jens Luedicke <jens.luedicke@gmail.com>
Subject: Re: if statement oddity
Message-Id: <4244676d$0$11476$9b4e6d93@newsread2.arcor-online.net>

Felix Geerinckx wrote:

> 
> The assignment isn't enclosed in parentheses. The full statement is
> enclosed in double parentheses.
> 

shit. little typo. big confusion.

mea culpa! shame on me...

/me hides

-- 
Jens Luedicke
web: http://perldude.de


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

Date: Fri, 25 Mar 2005 19:34:23 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: if statement oddity
Message-Id: <d21op3$2ea$1@sun3.bham.ac.uk>



Jens Luedicke wrote:

> Hiya..
> 
> I encountered a strange problem with an if () statement:
> 
> if ((my $r = &{$self->{onFile}}($path) != SUCCESS)) {
>     return $r;
> }
> 
> The above code seems to ignore the return value of the function
> and somehow overrides it. the return value of the called function
> returns FAILED, but $r doesn't reflect that!?

Er?  Assuming FAILED != SUCCESS then $r will be set to false.  I can't 
recell off the top of my head which false but since it immediately goes 
out of scope this doesn't matter.


> 
> The following code, works as expected:
> 
> my $r = &{$self->{onFile}}($path);
> 
> if ($r != SUCCESS)) {
>     return $r;
> }

No, that contains a syntax error and will not compile.

> fyi, SUCCESS is a constant. use constant SUCCESS => 1;
> 
> both code examples should work the same. no matter what!?
> 
> do I miss something? I'm a little disturbed right now.

I'm betting you meant

if ((my $r = &{$self->{onFile}}($path)) != SUCCESS) {
     return $r;
}

Can I suggest that in future you produce a _minimal_ but _complete_ 
example that you have actually run and found to behave as you don't 
expect.  Post it together with a precices description of what it did and 
what you expected.

This advice and much other useful advice can be found in the posting 
guidelines.



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

Date: Fri, 25 Mar 2005 13:47:55 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: if statement oddity
Message-Id: <slrnd48qnb.cn5.tadmc@magna.augustmail.com>

Jens Luedicke <jens.luedicke@gmail.com> wrote:

> I encountered a strange problem with an if () statement:

[snip]

> do I miss something? 


Yes.

You missed posting a short and complete program that we can run
that illustrates the problem you are having.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 25 Mar 2005 21:07:18 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: if statement oddity
Message-Id: <3aj98rF68r2qnU1@individual.net>

Jens Luedicke wrote:
> Gunnar Hjalmarsson wrote:
>> How about enabling warnings? Using the string 'FAILED' in a numerical 
>> comparison isn't very wise.
> 
> I use warnings.

Good.

> FAILED and SUCCESS are numerical constants.

I see. But you failed to explain that as regards FAILED.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Fri, 25 Mar 2005 21:24:24 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: if statement oddity
Message-Id: <3aja9hF6bnmj2U1@individual.net>

Brian McCauley wrote:
> Jens Luedicke wrote:
>>
>> if ((my $r = &{$self->{onFile}}($path) != SUCCESS)) {
>>     return $r;
>> }
> 
> Er?  Assuming FAILED != SUCCESS then $r will be set to false.

Suppose you mean true, i.e. 1.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Fri, 25 Mar 2005 21:23:21 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: if statement oddity
Message-Id: <d21v5c$5dv$1@sun3.bham.ac.uk>



Gunnar Hjalmarsson wrote:

> Brian McCauley wrote:
> 
>> Jens Luedicke wrote:
>>
>>>
>>> if ((my $r = &{$self->{onFile}}($path) != SUCCESS)) {
>>>     return $r;
>>> }
>>
>>
>> Er?  Assuming FAILED != SUCCESS then $r will be set to false.
> 
> 
> Suppose you mean true, i.e. 1.

Yes I mean true.



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

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


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