Re: RegExp Question

2001-02-05 Thread Philip Newton

John Giordano wrote:
 $grep_deferred = system ('findstr DeferredStatus response1');
 
 print "$grep_deferred\n\n";
[snip]
 $grep_deferred has this in it:
 
 a href="/c9410ee04de9845704db8951dfde015b/DeferredStatus"img
 src="/images/btnstats.gif" width=120 height=40 border=0 alt="Mail
 Status"/a

Are you sure? Try printing out "bloop\nblip\n$grep_deferred\nblep\n" and see
whether this a href line comes between "blip" and "blep".

From `perldoc -f system`:

 The return value is the exit status of the program as returned
 by the `wait' call. To get the actual exit value divide by 256.

So if $grep_deferred is the return value from system, it's probably a
number. The line you're seeing on the screen is presumably the output of
findstr, which went to STDOUT; since you didn't redirect STDOUT, it went the
same place your print went.

You probably want `` (backticks).

ObTMTOWTDI: if you're looking for a fixed substring such as 'a ', then
consider using index() rather than regular expressions. See useless
benchmark at the end.

Cheers,
Philip

#!perl -w

use strict;
use Benchmark 'cmpthese';

cmpthese(5_000_000, {
  'index.start.found'= sub { $a = index 'a
href="/c9410ee04de9845704db8951dfde015b/DeferredStatus"img
src="/images/btnstats.gif" width=120 height=40 border=0 alt="Mail
Status"/a', 'a '; },
  'index.start.notfound' = sub { $a = index '[a
href="/c9410ee04de9845704db8951dfde015b/DeferredStatus"img
src="/images/btnstats.gif" width=120 height=40 border=0 alt="Mail
Status"/a', 'a '; },
  'regex.start.found'= sub { $a = 'a
href="/c9410ee04de9845704db8951dfde015b/DeferredStatus"img
src="/images/btnstats.gif" width=120 height=40 border=0 alt="Mail
Status"/a' =~ /a /; },
  'regex.start.notfound' = sub { $a = '[a
href="/c9410ee04de9845704db8951dfde015b/DeferredStatus"img
src="/images/btnstats.gif" width=120 height=40 border=0 alt="Mail
Status"/a' =~ /a /; },
  'index.end.found'  = sub { $a = index 'fhuhge8a goija fgoja w04gua
roigj oöijf g9a8u onigö lfsdkj gölija osij ga0 jügojar öoigj öosijd ü08g9u
gaji fäöigjah+w r0g9j aäüjäfpoiajs öoijfd +ajsd fäüpioaj öwoeijf öoasuidhf
p9iawh üefhaj woeijg awopihg apiuehrg üaiowj eoöfigjaw ejifa
href="/c9410ee04de9845704db8951dfde015b/DeferredStatus"img
src="/images/btnstats.gif" width=120 height=40 border=0 alt="Mail
Status"/a', 'a '; },
  'index.end.notfound'   = sub { $a = index 'fhuhge8a goija fgoja w04gua
roigj oöijf g9a8u onigö lfsdkj gölija osij ga0 jügojar öoigj öosijd ü08g9u
gaji fäöigjah+w r0g9j aäüjäfpoiajs öoijfd +ajsd fäüpioaj öwoeijf öoasuidhf
p9iawh üefhaj woeijg awopihg apiuehrg üaiowj eoöfigjaw ejif[a
href="/c9410ee04de9845704db8951dfde015b/DeferredStatus"img
src="/images/btnstats.gif" width=120 height=40 border=0 alt="Mail
Status"/a', 'a '; },
  'regex.end.found'  = sub { $a = 'fhuhge8a goija fgoja w04gua roigj
oöijf g9a8u onigö lfsdkj gölija osij ga0 jügojar öoigj öosijd ü08g9u gaji
fäöigjah+w r0g9j aäüjäfpoiajs öoijfd +ajsd fäüpioaj öwoeijf öoasuidhf p9iawh
üefhaj woeijg awopihg apiuehrg üaiowj eoöfigjaw ejifa
href="/c9410ee04de9845704db8951dfde015b/DeferredStatus"img
src="/images/btnstats.gif" width=120 height=40 border=0 alt="Mail
Status"/a' =~ /a /; },
  'regex.end.notfound'   = sub { $a = 'fhuhge8a goija fgoja w04gua roigj
oöijf g9a8u onigö lfsdkj gölija osij ga0 jügojar öoigj öosijd ü08g9u gaji
fäöigjah+w r0g9j aäüjäfpoiajs öoijfd +ajsd fäüpioaj öwoeijf öoasuidhf p9iawh
üefhaj woeijg awopihg apiuehrg üaiowj eoöfigjaw ejif[a
href="/c9410ee04de9845704db8951dfde015b/DeferredStatus"img
src="/images/btnstats.gif" width=120 height=40 border=0 alt="Mail
Status"/a' =~ /a /; },
  'assign'   = sub { $a = 1; },
});

__END__

Output:
Benchmark: timing 500 iterations of assign, index.end.found,
index.end.notfound, index.start.found, inde
x.start.notfound, regex.end.found, regex.end.notfound, regex.start.found,
regex.start.notfound...
assign:  0 wallclock secs ( 1.02 usr +  0.00 sys =  1.02 CPU) @
4897159.65/s (n=500)
index.end.found:  9 wallclock secs ( 9.79 usr +  0.00 sys =  9.79 CPU) @
510516.64/s (n=500)
index.end.notfound: 12 wallclock secs (12.38 usr +  0.00 sys = 12.38 CPU) @
404007.76/s (n=500)
index.start.found:  3 wallclock secs ( 2.49 usr +  0.00 sys =  2.49 CPU) @
2004811.55/s (n=500)
index.start.notfound:  5 wallclock secs ( 5.42 usr +  0.00 sys =  5.42 CPU)
@ 922849.76/s (n=500)
regex.end.found: 12 wallclock secs (11.42 usr +  0.00 sys = 11.42 CPU) @
437943.42/s (n=500)
regex.end.notfound: 13 wallclock secs (13.34 usr +  0.00 sys = 13.34 CPU) @
374840.69/s (n=500)
regex.start.found:  5 wallclock secs ( 3.91 usr +  0.00 sys =  3.91 CPU) @
1280081.93/s (n=500)
regex.start.notfound:  7 wallclock secs ( 6.38 usr +  0.00 sys =  6.38 CPU)
@ 783821.92/s (n=500)
  Rate regex.end.notfound index.end.notfound
regex.end.found index.end.found regex.start.notfound index.start.notfound
regex.start.found index.start.found assign
regex.end.notfound374841/s  

Re: Check if a process is running????

2001-02-05 Thread Alloun, Jonathan
Title: Re: Check if a process is running






Hello,


I am using Activestate's Perl 5.6 version and before I run my Perl script I need to check if there already is a process running??

I will be scheduling the Perl script with Winat but before the script is run, I want to make sure there is not already one running. (Since my script will be scheduled to run more than once.)

Does anyone know if there is something in Perl to enable me to check what the current running processes are on the NT box???

Any examples of code greatly appreciated.


Many thanks,


Jonathan





RE: Disk space and free disk space

2001-02-05 Thread Goodier, Colin R

Hi,

Take a look at the example scripts for the 'Perl for Windows System
Administration' book on O'Reilly's site. There's an ADSI script in there
that shows the free disk space.

Colin


 -Original Message-
 From: Asif Kaleem [SMTP:[EMAIL PROTECTED]]
 Sent: 01 February 2001 21:54
 To:   [EMAIL PROTECTED]
 Subject:  Disk space and free disk space
 
 Hello:
 
 Is there a way to find out out how big the hard drive is and 
 how much free space is available using Perl on win NT box?
 
 Thanks in Advance.
 
 
 =
 Thanks a Mil-en,
 --Asif Kaleem
 
 __
 Get personalized email addresses from Yahoo! Mail - only $35 
 a year!  http://personal.mail.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: Check if a process is running????

2001-02-05 Thread Martin Moss

ooops I forgot to mention that this lockfile system allows multiple
instances of my script, just as long as each one is processing something
different. Hence the split and multiple lines!!
However I'm sure you get the gist now.

Marty

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]]On Behalf Of
 Martin Moss
 Sent: Monday 05 February 2001 10:58
 To: Alloun, Jonathan
 Cc: Perl-Win32-Users Mailing List
 Subject: RE: Check if a process is running


 Hi Jonathan,


 I'm not so sure about Windows perl, but In unix I use a couple of simple
 subroutines:-
 As long as the Kill command works in a simillar way you're fine, otherwise
 I'd be interested to know how it's done myself.

 CheckLock;

 sub CheckLock
 {
 my %locks=();
 if (-e $LOCKFILE)
 {
 open (LOCK, "$LOCKFILE");
 while (my $line=LOCK)
 {
 chomp $line;
 my ($locksyndicate,$pid)=split (/,/,$line);
 $locks{$locksyndicate}=$pid;
 }
 close (LOCK);


 my $pid=$locks{$Syndicate};

 if ($pid)
 {

 if (kill 0= $pid)
 {
 die "process already running with PID
 $pid\n";
 }
 else
 {
 $locks{$Syndicate}=$$;
 WriteLockFile(\%locks);
 }
 }
 }
 else
 {
 $locks{$Syndicate}=$$;
 WriteLockFile(\%locks);
 }
 }

 sub WriteLockFile
 {
 my $locks=shift;
 my %locks=%$locks;

 open(LOCK, "$LOCKFILE");
 foreach my $key(keys (%locks))
 {
 print LOCK "$key,$locks{$key}\n";
 }
 close (LOCK);
 }

 ___
 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: Win32::API -- keybd_event

2001-02-05 Thread Aldo Calpini

Rafala, Michael wrote:
 I've got a script that uses Win32::API to send an Esc key command
 to the application with the focus.

 Because API.pm is not included in the standard release of
 ActivePerl, I'd rather not have to use it.

 Is there another way to accomplish this?

yes, you can use the FFI module (not included in the standard
release :-).
if you want to have C functionalities without installing any
additional Perl modules, you can always write a program in C!
once you have installed Perl, installing Perl modules (even
automatizing their installation) is not that difficult. YMMV.


cheers,
Aldo

__END__
$_=q,just perl,,s, , another ,,s,$, hacker,,print;


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



RE: Ptk - Titlebar color, Window icons

2001-02-05 Thread Joseph P. Discenza

Marcus wrote, on Saturday, February 03, 2001 00:36
: On 02.02.01 at 17:44 Scott F wrote:
: This is a system-wide setting in Control Panel|Display on the
: Appearance
: tab.
: 
: I'm trying to change it from a Tk program for the application it
: creates.

These values are stored in the registry (at least in Win98), which
you can manipulate from Perl. The keys are in

HKCU\Control Panel\Colors\

Try ActiveTitle  InactiveTitle. The numbers appear to be R G B
triples.

I've never messed with the registry from Perl, so I won't try to
advise you there, but I believe Win32::Registry comes with ActivePerl.

Joe

==
  Joseph P. Discenza, Sr. Programmer/Analyst
   mailto:[EMAIL PROTECTED]
 
  Carleton Inc.   http://www.carletoninc.com
  219.243.6040 ext. 300fax: 219.243.6060
 
Providing Financial Solutions and Compliance for over 30 Years

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



Re: nmake was Re: modules compilation problem: missing separator????

2001-02-05 Thread Steven Wadding

At 04:48 PM 2/5/01 +1100, Sisyphus wrote:
Hi,
There's probably a later version of nmake than the one my link downloads :-)
Stuffed if I can find it, however.

I did manage to find nmake15.exe on the Microsoft FTP site, from home.  I 
hadn't found it before because I can't seem to get to FTP site from work, I 
suspect because of the firewall.  The date on the extracted nmake.exe is in 
1994, so I can see why you think there must be a later version.

Steve W.

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



Re: More efficient way to write?

2001-02-05 Thread SCOTT_SISSON


It looks like you got you answer, but here are a couple of other ideas.

Instead of using /i in your regex - you can uc() or lc() the string first -
I think this may be more efficient.

Also,  ['html', 'htm', 'doc'] can be written somehting like

/\.htm[l]|\.doc/ (not tested- I think it is the correct format)



   
  
"jim" [EMAIL PROTECTED]  
  
Sent by: To: 
[EMAIL PROTECTED]
[EMAIL PROTECTED]cc:   
  
eState.com   Subject: More 
efficient way to write?   
   
  
   
  
02/02/01 10:46 PM  
  
   
  
   
  


hi perl friends,

is there a more efficient/elegant way to write line no. 11 below?

thanks!


#!perl.exe -w

use File::Find; #line 1
use strict; #line 2
my %dir; #line3
my $suffix = ['html', 'htm', 'doc']; #line 4
my $path = 'c:/hdb'; #line 5
find(\wanted, $path); #line 6
 foreach (keys %dir) { #line 7
 print "$_ - $dir{$_} $$suffix[0] files\n" #line 8
}#line 9
sub wanted { #line 10
return unless /\.$$suffix[0]|\.$$suffix[1]|\.$$suffix[2]|/i; #line 11
$dir{"$File::Find::dir"}++; #line 12
1; #line 13
} #line 14

___
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