Re: Easy way of using module Env, platform independent?

2004-11-08 Thread zeray . abraha




Thanks Roger.
I will use the hint you gave me and will further explore/modify it to fit
my requirement.

Regards,
Zeray




  

  
To:   
'[EMAIL PROTECTED]'   
 
[EMAIL PROTECTED]  
cc:   
(bcc: Zeray Abraha/WLR/SC/PHILIPS)  

Subject:Re: Easy way of using module Env, platform independent?   
   Roger Keane [EMAIL PROTECTED]  


Classification:   
   Sent by: 
  
   [EMAIL PROTECTED]
  
   .com 
  

  
   2004-11-05 16:51 
  

  

  




[EMAIL PROTECTED] wrote:




 # Hi,
 # Question. Easy way of using module Env, platform independent.
 # Want to do the following: (example)
 # 1. get the PATH environment variable
 # 2. change it to add an additional search path
 # 3. put back the modified PATH
 # 4. execute a program/script using the system command.
 # Example below works but I don't like it. There must be an easy way,
 similar to setenv(env_varName=value)
 # that also takes care of the platform independence.
 # Your help is appreciated.

 use strict;
 my @PATH=();
 use Env; # Env qw(PATH);
 my $mswin=0;
 my $home=;
 $mswin=1 if ($^O =~ /MSWin/);

 @PATH=split(/;/,$ENV{'PATH'}) if $mswin; # for windows
 @PATH=split(/:/,$ENV{'PATH'}) if !$mswin;# for unix

 $home=$ENV{'HOMEPATH'} if $mswin;# for windows
 $home=$ENV{'HOME'} . '/' if !$mswin; # for unix

 print home=$home\n;

 my $toolpath=${home}tmp/bin;   # in this path is my
 executable
 $toolpath =~ s/\//\\/g if $mswin;# adjust for windows
 print toolpath=$toolpath\n;

 push(@PATH, $toolpath);  # add to the PATH
 environment variable
 $ENV{'PATH'}=join(($mswin)? ';':':', @PATH); # set the PATH env.
 thus
 print PATH=,$ENV{'PATH'}, \n;# see if toolpath is
 added

 # execute your program now using system command.
 # For this example, for unix, 'chmod +x ztest.bat'; ztest.bat prints
'some
 message'
 system(ztest.bat);
 print Unknown command\n if $?;

 # Thanks
 # zeray

If you version of Perl is recent enough (5.6.0 or better, I think) the
array support for the path-like variables is already built-in to the Env
module, and is platform independent (uses the $Config{path_sep} variable).
You still need to be wary of path directory separators.  There are platform
independent modules for constructing the pathnames (see File::Spec), but
here's a qnd approach that works for windoze XP and *nix:

testedcode
#!perl -w
use strict;
require v5.6.0;
use Env qw( @PATH $HOME $HOMEDRIVE $HOMEPATH );
sub isWindoze() { return $^O =~ /Win32/; }
sub getHome() { return isWindoze() ? $HOMEDRIVE . $HOMEPATH : $HOME; }
sub add_paths(@)
{
 my @paths = @_;
 my $dir_sep = isWindoze() ? \\ : /;
 push @PATH, map{ s/[\/\\]+/${dir_sep}/go; $_ } @paths;
}

my $home = getHome() || die( you are homeless!\n );
print( Before add_paths:\n   , join(\n   , @PATH), \n );
add_paths( $home/tmp/bin, temp, $home/temp, ///temp );
print( After add paths:\n   , join(\n   , @PATH), \n );
/testedcode

Several things to think about (left as an exercise for 

RE: Perl-Win32-Users Digest, Vol 10, Issue 6

2004-11-08 Thread Dave Budd
$tempstr =~ s/(\r?\n)|(\r[^\n])|(\r$)/br/g;

He said spaces, though, so br isn't really what he wants. Is it?
And these days, shouldn't it be br / anyway (plus appropriate escape
for the /)?


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Perl-Win32-Users Digest, Vol 10, Issue 7

2004-11-08 Thread Dave Budd
What is description,bin_data,filename,filesize,filetype?and how to get
these imformaton from perl?

They are the names of fields within the table being accessed by the
MySQL query.
A visit to www.mysql.com to have a look at the documentation might be
good.
If your Perl does a use DBI;you can send any MySQL command to
the database and get the results back into Perl variables. Spend some
time reading the documentation for the DBI module. A few 10 minute
sessions now and then was enough for what I needed to know when I
started using Perl with MySQL.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regex question: Multiple instances of the same character

2004-11-08 Thread Joseph Discenza
Ted Schuerzinger wrote, on Saturday, November 06, 2004 3:29 PM
:  I'm an avid, but not very good, Scrabble player.  Last night, I was  
:  playing, and suffered a major brain cramp when I got a rack 
:  of four vowels  
:  *and* two blanks: AEIUR**.  I couldn't come up with anything 
:  at the time,  
:  so this morning wrote a simple Perl script using a regex:
:  
:  if ($_ =~/\b[a-z]{7}\b/i  $_ =~/A/i  $_ =~/E/i  $_ 
:  =~/I/i  $_  
:  =~/R/i  $_ =~/U/i)
:  
:  to find all seven-letter words in the official Tournament 
:  Word List that  
:  have an A, E, I, U, and R.  The script dutifully produced 33 
:  valid words,  
:  embarrassing me by showing that I missed such common words 
:  as ACQUIRE and  
:  FAILURE.  :-)  (On the other hand, I now know the word 
:  RESIDUA, which  
:  should be useful since I know I've had that rack before)
:  
:  Now for my question: the above regex was fairly easy to come 
:  up with.  But  
:  how would I go about coming up with an efficient regex for 
:  those cases  
:  where the rack contains more than one of the same non-blank? 

I haven't seen anyone recommend this: /T.*T/i to match two 'T's. I'm not
going to compare this to $Bill's word-matching routine :).

Good luck,

Joe

==
  Joseph P. Discenza, Sr. Programmer/Analyst
   mailto:[EMAIL PROTECTED]
 
  Carleton Inc.   http://www.carletoninc.com
  574.243.6040 ext. 300fax: 574.243.6060
 
Providing Financial Solutions and Compliance for over 30 Years
* Please note that our Area Code has changed to 574! *  



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: [Swprograms] Auroral reports

2004-11-08 Thread Ted Schuerzinger
Richard Cuff graced hard-core-dx.com with these words of wisdom:

 I got my kids out of bed -- 7 and 12 - very visible, including
 shimmering  streaking...best here in years...
 
 QTH:  Allentown, PA  USA

You're lucky.  All I saw was a pinkish glow that looked like it was from 
one of those old two-color Technicolor films from before they had a blue 
filter, and everything looks pink and green and brown

-- 
Ted fedya at bestweb dot net
Barney: Hey, Homer, you're late for English.
Homer: Who needs English?  I'm never going to England.  
http://www.snpp.com/episodes/7F12.html
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: [Swprograms] Auroral reports

2004-11-08 Thread Ted S.
Ted Schuerzinger graced perl with these words of wisdom:

 Richard Cuff graced hard-core-dx.com with these words of wisdom:
 
 I got my kids out of bed -- 7 and 12 - very visible, including
 shimmering  streaking...best here in years...
 
 QTH:  Allentown, PA  USA
 
 You're lucky.  All I saw was a pinkish glow that looked like it was
 from one of those old two-color Technicolor films from before they had
 a blue filter, and everything looks pink and green and brown

Sorry for sending this to the wrong group.  I hope the rest of you in the 
higher latitudes got a good look at the Northern Lights last night.  :-)

-- 
Ted fedya at bestweb dot net
Barney: Hey, Homer, you're late for English.
Homer: Who needs English?  I'm never going to England.  
http://www.snpp.com/episodes/7F12.html
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Extracting Images Question

2004-11-08 Thread Thomas, Mark - BLS CTR
 I wish it was that easy, I could have a script ftp and grab 
 them. Our company is very funny and does not work well 
 between the different depts, so getting ftp access to a 
 directory on another computer on the other side of the world 
 won't happen. How hard is it to do what I stated in my original post?

It's easy with WWW::Mechanize, as stated in an earlier response.

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regex question: Multiple instances of the same character

2004-11-08 Thread Ted Schuerzinger
Joseph Discenza graced perl with these words of wisdom:

 I haven't seen anyone recommend this: /T.*T/i to match two 'T's. I'm not
 going to compare this to $Bill's word-matching routine :).

That's such a simple solution, and it seems to work.  In a previous post, 
I wrote:

 As an example, suppose I have AEEIRST as my seven letters.  What 
 eight-letter words can I make that have those seven letters in them? 
 (The eighth letter, of course, would be something already on the board 
 that you play through.)  I can think of several offhand (EATERIES, 
 TEARIEST, TREATIES, TREATISE, and WEARIEST), but I'd like to have a 
 script that I can use after the game to show me what I missed. 

It turns out there are apparently 23 words I missed, as this was the 
script's output:

ARENITES  ARIETTES  ARSENITE  ARTERIES  ATELIERS  EARLIEST  EATERIES  
EMIRATES  HEARTIES  ITERATES  LEARIEST  PARIETES  READIEST  REALTIES  
RESINATE  SERIATED  SERIATES  STEADIER  STEAMIER  STEARINE  SWEATIER  
TEARIEST  TRAINEES  TREATIES  TREATISE  WASTERIE  WEARIEST  YEASTIER

I guess the reason I didn't think of your solution is that I'm just as 
lousy a programmer as I am a Scrabble player.  :-)

-- 
Ted fedya at bestweb dot net
Barney: Hey, Homer, you're late for English.
Homer: Who needs English?  I'm never going to England.  
http://www.snpp.com/episodes/7F12.html
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs