RE: perl in windows.

2001-06-18 Thread Joe Schell



 -Original Message-
 Behalf Of $Bill Luebkert

 Joe Schell wrote:
 
   -Original Message-
   Behalf Of $Bill Luebkert
  
   Andy Jennings wrote:
   
Michael
   
On NT/2000 default installation of AS Perl will associate
   filetypes in IIS -
.pl to perl.exe and .plx to PerlIS.dll. There is no need to
   have the shebang
line to define the interpreter as the webserver will
   automatically select it
according to file extension.
  
   That assumes you are using IIS and not Apache or some other
 server which
   is not in the immediate list of assumptions.  On Apache, it would
   be either
   the full path to Perl (eg: #!c:/perl/bin/perl) or possibly
 just #!perl if
   in the path or nothing at all if using registry option.
 
  I thought the path requirement (c:/perl/bin/perl) stopped being
 true a while
  ago.  I don't believe I have the 'registry option' (is that a
 module?) and
  all I use is #!perl.

 What does that mean 'stopped being true' ?


At one point the path to perl had to be specified in the shebang line.  I
remember because it was annoying going back and forth between windows and
unix with the path change.  So when it started allowing the use of just
'#!perl' I noted it.

 If perl is not in your path,
 how do you expect Apache to find the Perl exe ?

I was referring to the explicit usage of the path to perl in the shebang
line.  I don't use it and haven't used it for at least a year and maybe two.


 This (in httpd.conf) is for using registry to find Perl:

   ScriptInterpreterSource registry

Nope I don't have that specified in my configuration.

Just to be sure I modified the shebang line in one of my scripts (perl =
perlxx).  It failed.  So it is using the shebang line.


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Unable to get Attachment working w/Lotus Notes

2001-06-18 Thread Brad Currens

Has anyone had success attaching a file to a Lotus
Notes email using Perl?  I have the following script
which sends the email, but, so far no attachment.

TIA
Brad

use Win32::OLE;
use Win32::OLE::Variant;

$file = c:\\sstrm60\\batch\\pcareport.xls;

send_mail('Brad Currens','@anywhere.com');

sub send_mail {
my($name, $notesdomain) = @_;
my($session, $db, $doc, $body);

$session = Win32::OLE-new('Notes.NotesSession')
  or die Cannot start Lotus Notes Session
object.\n;

$db = $session-GetDatabase( '' , '');
$db-OpenMail;

$doc = $db-CreateDocument;
$doc-{'Form'} = 'Memo';
$doc-{'SendTo'} = [$name$notesdomain];
$doc-{'CopyTo'} = [];
$doc-{'Subject'} = 'PCA Interface Report';
$body = '__STOP_IT';
PCA Interface attachment.
__STOP_IT

$doc-{'Body'} = $body;

$rtitem = $doc-CreateRichTextItem( PCA Report
);
$object =
$rtitem-EmbedObject(EMBED_ATTACHMENT,,c:\\sstmr60\\batch\\pcareport.xls);

$doc-save(1,1);
$doc-send(1);

return();
}


__
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



computations with backreferences

2001-06-18 Thread Dan Jablonsky

Hi all,
I have a regex, it's isolating some numbers in each
line of a text file and I want to add some computation
with those numbers on the same line. I know you can
basically stick any function in a regex but I don't
know how. Hence, the code below won't work:

$_=~s/^[A-Z]\t(\d{1,2})\t.*\t(\d{2})\t.*/$1\t$2\t($1+$2)/2/;

The forward slash that would terminate wrongly the
regex is actually a divide by.
What is the correct way to do it?
Thanks,
Dan

__
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: computations with backreferences

2001-06-18 Thread Arthur Cohen

: I know you can
: basically stick any function in a regex but I don't
: know how. Hence, the code below won't work:

To evaluate the right side of a substitution as an expression (rather
than a literal string), you stick an e after the last delimiter. 
 
: $_=~s/^[A-Z]\t(\d{1,2})\t.*\t(\d{2})\t.*/$1\t$2\t($1+$2)/2/;
: 
: The forward slash that would terminate wrongly the
: regex is actually a divide by.
: What is the correct way to do it?

You can use any delimiters you like in your substitution, either a
single character like:

s|foo|bar|

or matched pairs like

s{foo}{bar}

--Art

 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Regular Expression, matching dates

2001-06-18 Thread steve silvers

I need a regular expression that will match dates in the following format.

January 01, 2001
January 15, 2001
February 01, 2001

so on. All dates are spelled out March, April, May...

Any suggestions.
Thanks in advance.
Steve.
_
Get your FREE download of MSN Explorer at http://explorer.msn.com

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Regular Expression, matching dates

2001-06-18 Thread Arthur Cohen

: 
: I need a regular expression that will match dates in the 
: following format.
: 
: January 01, 2001
: January 15, 2001
: February 01, 2001
: 
: so on. All dates are spelled out March, April, May...
: 

if ($date_string =~ /(\w+)\s+(\d{1,2}),\s+(\d{4})/) {
$month = $1;
$day = $2;
$year = $3;
}

You can make the regex as strict or as loose as you want. I've written
it to allow any number of white-space characters between each piece of
the date, but you may want to restrict it to only one space character.
OTOH, mine is require exactly 1 or 2 digits in the day and 4 in the
year, which you may want to adapt to suit your needs.

--Art
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Regular Expression, matching dates

2001-06-18 Thread Asif Kaleem

if we have the date like ber 11, 2001 or ugust 12, 2001 then the match is
ture whcih is not what we want.


--- Peter Eisengrein [EMAIL PROTECTED] wrote:
 untested...
 
 /[January|February|March|April|May|June|July|August|September|October|Novemb
 er|December]\s{0,}\d{1,2}\,\s{0,}\d{4}/
 
  -Original Message-
  From: steve silvers [mailto:[EMAIL PROTECTED]]
  Sent: Monday, June 18, 2001 3:00 PM
  To: [EMAIL PROTECTED]
  Subject: Regular Expression, matching dates
  
  
  I need a regular expression that will match dates in the 
  following format.
  
  January 01, 2001
  January 15, 2001
  February 01, 2001
  
  so on. All dates are spelled out March, April, May...
  
  Any suggestions.
  Thanks in advance.
  Steve.
  _
  Get your FREE download of MSN Explorer at http://explorer.msn.com
  
  ___
  Perl-Win32-Users mailing list
  [EMAIL PROTECTED]
  http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
  
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users


=
Thanks a Mil-¥en,
--Asif Kaleem

__
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Regular Expression, matching dates

2001-06-18 Thread Peter Eisengrein

True. For that you could use /\w{1,}\s{0,}\d{1,2}\,\s{0,}\d{4}/ but that's
not what he asked for.

 -Original Message-
 From: Asif Kaleem [mailto:[EMAIL PROTECTED]]
 Sent: Monday, June 18, 2001 3:20 PM
 To: Peter Eisengrein; 'steve silvers';
 [EMAIL PROTECTED]
 Subject: RE: Regular Expression, matching dates
 
 
 if we have the date like ber 11, 2001 or ugust 12, 2001 
 then the match is
 ture whcih is not what we want.
 
 
 --- Peter Eisengrein [EMAIL PROTECTED] wrote:
  untested...
  
  
 /[January|February|March|April|May|June|July|August|September|
 October|Novemb
  er|December]\s{0,}\d{1,2}\,\s{0,}\d{4}/
  
   -Original Message-
   From: steve silvers [mailto:[EMAIL PROTECTED]]
   Sent: Monday, June 18, 2001 3:00 PM
   To: [EMAIL PROTECTED]
   Subject: Regular Expression, matching dates
   
   
   I need a regular expression that will match dates in the 
   following format.
   
   January 01, 2001
   January 15, 2001
   February 01, 2001
   
   so on. All dates are spelled out March, April, May...
   
   Any suggestions.
   Thanks in advance.
   Steve.
   _
   Get your FREE download of MSN Explorer at http://explorer.msn.com
   
   ___
   Perl-Win32-Users mailing list
   [EMAIL PROTECTED]
   http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
   
  ___
  Perl-Win32-Users mailing list
  [EMAIL PROTECTED]
  http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
 
 
 =
 Thanks a Mil-¥en,
 --Asif Kaleem
 
 __
 Do You Yahoo!?
 Spot the hottest trends in music, movies, and more.
 http://buzz.yahoo.com/
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Regular Expression, matching dates

2001-06-18 Thread Cornish, Merrill

Steve,

There are several other questions that need to be asked before you can
decide on a regular expression:

* Is there a possiblity of typos in the month names?

* Can the month names sometimes be in all uppercase?

* Can there be more than one space between month and day or comma and year?
Can there sometimes be no spaces?

* Will the comma always be there?

* Will it always be a four digit year?

* Will the day always be two digits?

* Does this date appear on a line with other text that may confuse simple
patterns?  For example, 

(\S+)(\S+), (\S+) 

is sufficient for what you have shown us; but it would it would also
recognize any three words with a comma after the second word.  So the
question is how tight do you need ot make the pattern.

Merrill
-Original Message-
From: steve silvers [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 18, 2001 2:00 PM
To: [EMAIL PROTECTED]
Subject: Regular Expression, matching dates


I need a regular expression that will match dates in the following format.

January 01, 2001
January 15, 2001
February 01, 2001

so on. All dates are spelled out March, April, May...

Any suggestions.
Thanks in advance.
Steve.
_
Get your FREE download of MSN Explorer at http://explorer.msn.com

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: computations with backreferences

2001-06-18 Thread Ron Hartikka

Could you clarify the question.

Example: If I get the input line

___

I want this output line 

___.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Dan
Jablonsky
Sent: Monday, June 18, 2001 2:32 PM
To: [EMAIL PROTECTED]
Subject: computations with backreferences


Hi all,
I have a regex, it's isolating some numbers in each
line of a text file and I want to add some computation
with those numbers on the same line. I know you can
basically stick any function in a regex but I don't
know how. Hence, the code below won't work:

$_=~s/^[A-Z]\t(\d{1,2})\t.*\t(\d{2})\t.*/$1\t$2\t($1+$2)/2/;

The forward slash that would terminate wrongly the
regex is actually a divide by.
What is the correct way to do it?
Thanks,
Dan

__
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: computations with backreferences

2001-06-18 Thread Joe Schell



 -Original Message-
 On Behalf Of Dan Jablonsky
 
 Hi all,
 I have a regex, it's isolating some numbers in each
 line of a text file and I want to add some computation
 with those numbers on the same line. I know you can
 basically stick any function in a regex but I don't
 know how. Hence, the code below won't work:
 
 $_=~s/^[A-Z]\t(\d{1,2})\t.*\t(\d{2})\t.*/$1\t$2\t($1+$2)/2/;
 

Perhaps this...

$_ =~ s!^[A-Z]\t(\d{1,2})\t.*\t(\d{2})\t.*!$1\t$2\t . ($1+$2)/2!e;
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Unable to get Attachment working w/Lotus Notes

2001-06-18 Thread SCOTT_SISSON


I have had success using MIME::Lite.  Here is code from a script that works
in production today.  Some of the names
have been changed to protect the innocent.


The script generates a log while processing and then e-mails it to a list
of users.

use MIME::Lite;
.
..
.
sub SendEmail {

 my ($ernum,$emsg,$emailto) = @_;

 my $errorline,$prog,$dir,$type;

 $subj = $emsg processing $0 activity for $fullpath\n;

 ($prog,$dir,$type) = fileparse($0,'\..*');

 $msg = new MIME::Lite
   From =$prog\@opalias.com,
 Subject  = $subj,
   Type = 'multipart/mixed';

 attach $msg
   Type = 'text',
   Data = PrintParams;
 #
 #do not really understand why I have to parse and send seperate
To lines.
 #It works this way and not with a , or ; seperated list - oh
well
 #
 foreach $to (split /,/, $emailto) {
  $msg-add (To = $to);
 }

 print \n$subj;

 close OUT;
 select (STDOUT);

 # print \nAttaching file $ol size (-s $ol);

 @stats = stat ($ol);

#print \n\$stats[7] is $stats[7];
 if (-s $ol) {
# print \nattempting to attach file\n;
  attach $msg
   Path = $ol,
   Type = 'file/text',
   Encoding = 'quoted-printable';

 }
 #Debug= 1

 MIME::Lite-send(smtp,your smtp server name, Timeout=30 );

 $x = $msg-send;

# print \n, 'Command MIME::Lite-send(smtp, your smtpserver name ,
Timeout=30)';
# print \n x is $x;
# print \n \$! is $!;
# print \n \$@ is $@;

# unlink $msgdir$hashkey.txt;

}


   
   
Brad Currens [EMAIL PROTECTED] 
   
Sent by: To: 
[EMAIL PROTECTED]
[EMAIL PROTECTED]cc:   
   
eState.com   Subject: Unable 
to get Attachment working
 w/Lotus Notes 
   
   
   
06/18/01 01:54 PM  
   
   
   
   
   



Has anyone had success attaching a file to a Lotus
Notes email using Perl?  I have the following script
which sends the email, but, so far no attachment.

TIA
Brad

use Win32::OLE;
use Win32::OLE::Variant;

$file = c:\\sstrm60\\batch\\pcareport.xls;

send_mail('Brad Currens','@anywhere.com');

sub send_mail {
my($name, $notesdomain) = @_;
my($session, $db, $doc, $body);

$session = Win32::OLE-new('Notes.NotesSession')
  or die Cannot start Lotus Notes Session
object.\n;

$db = $session-GetDatabase( '' , '');
$db-OpenMail;

$doc = $db-CreateDocument;
$doc-{'Form'} = 'Memo';
$doc-{'SendTo'} = [$name$notesdomain];
$doc-{'CopyTo'} = [];
$doc-{'Subject'} = 'PCA Interface Report';
$body = '__STOP_IT';
PCA Interface attachment.
__STOP_IT

$doc-{'Body'} = $body;

$rtitem = $doc-CreateRichTextItem( PCA Report
);
$object =
$rtitem-EmbedObject(EMBED_ATTACHMENT,,c:
\\sstmr60\\batch\\pcareport.xls);

$doc-save(1,1);
$doc-send(1);

return();
}


__
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: unlink problems

2001-06-18 Thread Frazier, Joe Jr


 Message: 10
 From: steve silvers [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: unlink problems
 Date: Mon, 18 Jun 2001 12:53:20 -
 
 Thanks for all your help so far with this. Im still having a 
 problem. Im 
 using this snippet of code that someone helped with.
 
 
 if ( opendir( DIR, 'mydir' ) ) {
   my @htm = grep { /\.html?$/i }
   readdir(DIR);
   closedir(DIR);
   print Here are the HTML files;
   print @htm\n\n;
   unlink(@htm); # I also tried unlink @htm;
 }

readdir returns a list of filenames:

perldoc -f readdir
readdir DIRHANDLE
Returns the next directory entry for a directory opened
by `opendir()'. If used in list context, returns all the
rest of the entries in the directory. If there are no
more entries, returns an undefined value in scalar
context or a null list in list context.

If you're planning to filetest the return values out of
a `readdir()', you'd better prepend the directory in
question. Otherwise, because we didn't `chdir()' there,
it would have been testing the wrong file.

opendir(DIR, $some_dir) || die can't opendir $some_dir:
$!;
@dots = grep { /^\./  -f $some_dir/$_ } readdir(DIR);
closedir DIR;

Basically, your in the wrong DIR!  I hope none of the files in the list
were files in your CWD or were not important...  before this section of
code, you can: 

a) build your path in a var, pass this to the opendir, prepend to each
file in the list using map( or inside a foreach block)

b) cd to the dir you need to be in.

Anyway, a couple of tips are: -e to see if file exists before opertating
on it and make sure to check your return values on function calls.  


 
 When I run this it prints out:
 
 Here are the HTML files... and lists the html files.
 but it dosen't delete them?
 
 Any suggestions?
 Steve.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: perl in windows.

2001-06-18 Thread $Bill Luebkert

Joe Schell wrote:
 
  What does that mean 'stopped being true' ?
 
 At one point the path to perl had to be specified in the shebang line.  I
 remember because it was annoying going back and forth between windows and
 unix with the path change.  So when it started allowing the use of just
 '#!perl' I noted it.

That has been allowed for some time now.

  If perl is not in your path,
  how do you expect Apache to find the Perl exe ?
 
 I was referring to the explicit usage of the path to perl in the shebang
 line.  I don't use it and haven't used it for at least a year and maybe two.

I use it so it's compatible with my ISP.  I store a copy of Perl in /usr/bin,lib.

  This (in httpd.conf) is for using registry to find Perl:
 
ScriptInterpreterSource registry
 
 Nope I don't have that specified in my configuration.

Didn't say you did, that's the way you tell Apache (Windoze version) to use 
the registry settings instead of shebang.  I don't use it, but presumably you 
could have your UNIX paths in your scripts and override with the above.

-- 
  ,-/-  __  _  _ $Bill Luebkert   ICQ=14439852
 (_/   /  )// //   DBE Collectibles   Mailto:[EMAIL PROTECTED] 
  / ) /--  o // //  http://dbecoll.webjump.com/ (Free Perl site)
-/-' /___/__/_/_ Castle of Medieval Myth  Magic http://www.todbe.com/
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: perl in windows.

2001-06-18 Thread Joe Schell


 -Original Message-
 Behalf Of $Bill Luebkert
 
 
 Joe Schell wrote:
  
   What does that mean 'stopped being true' ?
  
  At one point the path to perl had to be specified in the 
 shebang line.  I
  remember because it was annoying going back and forth between 
 windows and
  unix with the path change.  So when it started allowing the use of just
  '#!perl' I noted it.
 
 That has been allowed for some time now.
 

Whoops!  I missed the first part of the following (in your first response.)

...possibly just #!perl if 
in the path or nothing at all if 
using registry option.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Regex (and substitution) help

2001-06-18 Thread Denis Pleic

Hi Perlers,

I need some help with a regex I can't figure out.

In short, I need to enclose all occurences of certain "label" 
strings in a text file into '^' marks.

I.e., for example:

"See SAY_PLEASE_TXT and SAY_HELLO_TXT."

Those string codes *always* come in all caps, and with *at least* 
one underscore character.

The strings in capitals (with underscores) refer to string codes, 
which should be enclosed in special '^' marks, so that the above 
example should be changed to:

"See ^SAY_PLEASE_TXT^ and ^SAY_HELLO_TXT^."

I've managed to find some clues in Perl Cookbook, and got some
results with modified "all caps" recipe:

s/[^\Wa-z0-9]+\_/^$1^/g

but, instead of enclosing the label into carets, it *replaces* the
found text - and, besides, it does not find the whole string. In
short, the above produces:

"See ^^TXT and ^^TXT."

which is definitely NOT what I wanted :-)))

So, if anyone has any ideas and suggestions, I'd be more than 
grateful...


TIA,

Denis

-
--  Croatian Translation  Language Services   -- * [EMAIL PROTECTED]
+
Denis Pleic  | Phone: (+385) 42 230-751 
Vodnikova 15 | Fax: (+385) 42 231 598
HR-42000 Varazdin| Mobile: (+385) 98 798 323
 CROATIA | http://www.open.hr/~dpleic/indx-e.html

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Regex (and substitution) help

2001-06-18 Thread $Bill Luebkert

Denis Pleic wrote:
 
 Hi Perlers,
 
 I need some help with a regex I can't figure out.
 
 In short, I need to enclose all occurences of certain label
 strings in a text file into '^' marks.
 
 I.e., for example:
 
 See SAY_PLEASE_TXT and SAY_HELLO_TXT.
 
 Those string codes *always* come in all caps, and with *at least*
 one underscore character.
 
 The strings in capitals (with underscores) refer to string codes,
 which should be enclosed in special '^' marks, so that the above
 example should be changed to:
 
 See ^SAY_PLEASE_TXT^ and ^SAY_HELLO_TXT^.
 
 I've managed to find some clues in Perl Cookbook, and got some
 results with modified all caps recipe:
 
 s/[^\Wa-z0-9]+\_/^$1^/g
 
 but, instead of enclosing the label into carets, it *replaces* the
 found text - and, besides, it does not find the whole string. In
 short, the above produces:
 
 See ^^TXT and ^^TXT.
 
 which is definitely NOT what I wanted :-)))
 
 So, if anyone has any ideas and suggestions, I'd be more than
 grateful...

$_ = See SAY_PLEASE_TXT and SAY_HELLO_TXT.\n;

s/([A-Z]+_[A-Z_]+)/^$1^/g;  # assumes no leading _ possible

-- 
  ,-/-  __  _  _ $Bill Luebkert   ICQ=14439852
 (_/   /  )// //   DBE Collectibles   Mailto:[EMAIL PROTECTED] 
  / ) /--  o // //  http://dbecoll.webjump.com/ (Free Perl site)
-/-' /___/__/_/_ Castle of Medieval Myth  Magic http://www.todbe.com/
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Regex (and substitution) help

2001-06-18 Thread Andy Jennings

Denis

I think this will do the deal for you:-

$tagger = "See SAY_PLEASE_TXT and SAY_HELLO_TXT.";
$tagger =~ s/\b([A-Z]+_[A-Z_]+)\b/^$1^/g;
print "$tagger\n";

Andy


- Original Message - 
From: "Denis Pleic" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, June 18, 2001 5:49 PM
Subject: Regex (and substitution) help


 Hi Perlers,
 
 I need some help with a regex I can't figure out.
 
 In short, I need to enclose all occurences of certain "label" 
 strings in a text file into '^' marks.
 
 I.e., for example:
 
 "See SAY_PLEASE_TXT and SAY_HELLO_TXT."
 
 Those string codes *always* come in all caps, and with *at least* 
 one underscore character.
 
 The strings in capitals (with underscores) refer to string codes, 
 which should be enclosed in special '^' marks, so that the above 
 example should be changed to:
 
 "See ^SAY_PLEASE_TXT^ and ^SAY_HELLO_TXT^."
 
 I've managed to find some clues in Perl Cookbook, and got some
 results with modified "all caps" recipe:
 
 s/[^\Wa-z0-9]+\_/^$1^/g
 
 but, instead of enclosing the label into carets, it *replaces* the
 found text - and, besides, it does not find the whole string. In
 short, the above produces:
 
 "See ^^TXT and ^^TXT."
 
 which is definitely NOT what I wanted :-)))
 
 So, if anyone has any ideas and suggestions, I'd be more than 
 grateful...
 
 
 TIA,
 
 Denis
 
 -
 --  Croatian Translation  Language Services   -- * [EMAIL PROTECTED]
 +
 Denis Pleic  | Phone: (+385) 42 230-751 
 Vodnikova 15 | Fax: (+385) 42 231 598
 HR-42000 Varazdin| Mobile: (+385) 98 798 323
  CROATIA | http://www.open.hr/~dpleic/indx-e.html
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
 
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Regex (and substitution) help

2001-06-18 Thread Brian Gibson

Here is one thing I might do.

I would open another file for writing

open(RESULT,"c:\\results.txt");
This file is going to be the file
that gets written out with the fixed 'stuff'.

and then open up the file in question that you want to rip apart and edit.

open(READTHISFILE,"c:\\file_to_read_in.txt");

then use a while loop on the file you are reading in to read each line
one line at a time and the whole line gets placed in the "$_" variable.

while(READTHISFILE)  {

}


Then within those brackets of the while loop I might use the split
function in each line.  I would split the $_ variable into an array
according to where the spaces are in the file.

something like this

@array_of_line_words = split(/ /,"$_");

Now every time you read a line, you have the words
in the line in an array called @array_of_line_words.
What you can do next is use a foreach loop to check out what
each word in the line says.


 foreach $word (@array_of_line_words) {

}

Within these brackets check to see if the $word variable has an underscore
and if NOT then write it to the RESULTS file handle (with no space after
it).
If  the $word variable does have an underscore and contains capital letters
then write a ^ to the results file then the $word then another ^ instead of
writing
a space.  You will have to work on when to add a space and when to add a ^
and remove an end of line character.   Now that I think about it you might
want to do
a chomp($_); when you first take in the full line to remove the end of line
character
and then add it when you need it (after each foreach loop is done).

I find that it is much easier to rip through a file this way instead of
trying to write an all encompassing
1 liner that you will never be able to return to and trouble shoot in the
future.  I know that is not the typical way
a Perl 'developer' might approach this, I have heard that there are contests
to see who can write the
most complicated code in a 1 liner..  In short, I hope it helps!





- Original Message -
From: Denis Pleic [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, June 18, 2001 6:49 PM
Subject: Regex (and substitution) help


 Hi Perlers,

 I need some help with a regex I can't figure out.

 In short, I need to enclose all occurences of certain "label"
 strings in a text file into '^' marks.

 I.e., for example:

 "See SAY_PLEASE_TXT and SAY_HELLO_TXT."

 Those string codes *always* come in all caps, and with *at least*
 one underscore character.

 The strings in capitals (with underscores) refer to string codes,
 which should be enclosed in special '^' marks, so that the above
 example should be changed to:

 "See ^SAY_PLEASE_TXT^ and ^SAY_HELLO_TXT^."

 I've managed to find some clues in Perl Cookbook, and got some
 results with modified "all caps" recipe:

 s/[^\Wa-z0-9]+\_/^$1^/g

 but, instead of enclosing the label into carets, it *replaces* the
 found text - and, besides, it does not find the whole string. In
 short, the above produces:

 "See ^^TXT and ^^TXT."

 which is definitely NOT what I wanted :-)))

 So, if anyone has any ideas and suggestions, I'd be more than
 grateful...


 TIA,

 Denis

 -
 --  Croatian Translation  Language Services   -- * [EMAIL PROTECTED]
 +
 Denis Pleic  | Phone: (+385) 42 230-751
 Vodnikova 15 | Fax: (+385) 42 231 598
 HR-42000 Varazdin| Mobile: (+385) 98 798 323
  CROATIA | http://www.open.hr/~dpleic/indx-e.html

 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



fork and child processes

2001-06-18 Thread James McDermet

I have a script that I want to fork a child process that will start an
application, e.g. notepad.  Once notepad is closed I want the child
process to send a signal to the parent.  How would I do this in Windows?

my $pid = fork();
defined ($pid) or die Can't fork: $!;

if ($pid  0){exit};

print my PID is $$\n;
`notepad`;

while (1) {
socket_listening();
}


James



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



MQCONNX in MQSeries

2001-06-18 Thread Hirosi Taguti

Has anyone sucessed to connect to MQ by MQCONNX (not MQCONN) in module MQSeries,
MA89 perl support, without MQSERVER env nor AMQCLCHL.TAB?

I can't do this for long time.
I posted this to MQ mailing list. And I got response from the auther Mr. Moore
saying Debug by yourself, I am simply passing your parameters to the IBM routine.
No user responded to the ML.

My env:
Windows 2000 Pro
ActivePerl 622
MQSeries-1.14

MQ server is running on remote Solaris.


- MQTEST_connectx.pl
#!perl
#
# MQTEST_connectx.pl: test connectx to vigsq033
#
use MQSeries;
$QMGR  = QMA9011 ;# name of QM
#-#
#   MQ MQCONNX
#-#
print  MQCONNX...\n;
$Coption = { ChannelName= 'CLIENT.TO.SERVER',
 TransportType  = 'TCP',
 ConnectionName = 'vigsq033', };
$Hconn = MQCONNX($QMGR, $Coption, $CompCode, $Reason);
if ($CompCode != 0) { 
  print  MQCONNX error $CompCode, $Reason\n;
  ($ReasonText) = MQReasonToText($Reason);
  print $ReasonText\n;
  exit;
}
print  MQCONNX OK...\n;
exit;
#
-


- result
D:\A2JMQMQTEST_connectx.pl
 MQCONNX...
 MQCONNX error 2, 2059
Queue manager not available for connection.
D:\A2JMQ
-

--
[EMAIL PROTECTED]
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Different number of hash elements

2001-06-18 Thread Greg Wardawy

Hello all,

I'm having a problem with the hash table built by querying the database. I'm getting a 
different number of hash elements when I'm printing them from the while loop and from 
the foreach block. I don't need to count and print them but I wanted to check if I'm 
getting everything because I need to use the hash later.
Printing from the following while loop gives me 1235 key/value pairs (and this is 
correct):

###

while ( my @row = $SQL-fetchrow_array) {
$count1++;
my($upc_num,$item) = @row;
$upc_num=~ s/\s+//g;
($item =$item) =~ s/\s+$//;
$upc_itemlist{$upc_num} = $item;
print $count1:\t$upc_num/$upc_itemlist{$upc_num}\n;
}



and printing outside the loop gives me 1193 pairs:



foreach $upc_num(keys %upc_itemlist) {
$count2++;
print $count2:\t$upc_num/$upc_itemlist{$upc_num}\n;
}



Why am I missing 42 pairs? How can I trace down why it's happening?
TIA

Greg

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users