RE: Calling Acrobat Reader

2006-05-10 Thread Dirk Bremer

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Dirk Bremer
> Sent: Tuesday, May 09, 2006 14:49
> To: Active State Perl
> Subject: Calling Acrobat Reader
> 
> I'm developing a nice little program that will search a directory on
> another server and return the results based upon several search
> criteria. The files being listed as the result of the search are PDF
> files. I would like to offer an option in this program to 
> allow the user
> to select a file and then have the program start Acrobat 
> Reader opening
> the selected file.
> 
> I have all but this last bit down and I'll explain further. I have
> gotten to the part where the user selects the file and I am trying to
> open it with:
> 
> system('AcroRd32.exe',$List[$Reply][2]);
> 
> snip.

Thanks to all who responded and helped to put me on the right track. I
ended up with this that seems to work fine:

exec($List[$Reply][2]);

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Calling Acrobat Reader

2006-05-09 Thread Dirk Bremer
I'm developing a nice little program that will search a directory on
another server and return the results based upon several search
criteria. The files being listed as the result of the search are PDF
files. I would like to offer an option in this program to allow the user
to select a file and then have the program start Acrobat Reader opening
the selected file.

I have all but this last bit down and I'll explain further. I have
gotten to the part where the user selects the file and I am trying to
open it with:

system('AcroRd32.exe',$List[$Reply][2]);

I have verified that $List[$Reply][2] contains a fully qualified
UNC-path and filename. The results are:

'AcroRd32.exe' is not recognized as an internal or external command,
operable program or batch file.

So, we now know that the Acrobat Reader in not in the system path. In
fact, its exact location can very from machine to machine. On my
machine, it is:

C:\Program Files\Adobe\Acrobat 7.0\Reader

Note that based upon the version (dating back to 4.x), the path can
change. This would make it difficult using a brute-force approach to
locating the executable.

But Windows knows where AcroRd32.exe lives and knows that when you
double-click on a PDF-file to execute it.

How can I emulate this behavior so that the Perl program can determine
no matter where the executable lives on a given user's PC, and for that
matter, whatever the executable name is that is associated with opening
PDF-files is, the executable name and its path. I would imagine that
this will require some search of the registry which I have no experience
with from within Perl. I would like any methodology to be used to be
relatively fast in locating the executable. 

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Replace Leading Spaces

2006-04-07 Thread Dirk Bremer


Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Nelson R. Pardee
> Sent: Friday, April 07, 2006 13:20
> To: Active State Perl
> Subject: RE: Replace Leading Spaces
> 
> Try # 2:
> The first is my new one using a positive lookahead assertion.
> I've included timings for 1 iterations for each of the proposed
> solutions.
> 
> 0.056398  s/\s(?=\s*\S)/0/og
> 0.254457  while (s/\s(?=(\d|\.))/0/ {)
> 0.094268 s/^(\s+)(?=\d)/'0'x(length $1)/e
> 

Nelson,

Please add Mark Thomas' solution to your timings to see how it compares
to the others:

s/ (?=.*\d)/0/g

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Replace Leading Spaces

2006-04-07 Thread Dirk Bremer

> -Original Message-
> From: Thomas, Mark - BLS CTR [mailto:[EMAIL PROTECTED] 
> Sent: Friday, April 07, 2006 13:15
> To: Dirk Bremer; Perl-Win32-Users@listserv.ActiveState.com
> Subject: RE: Replace Leading Spaces
> 
> > Using a regex, I want to replace each leading space-character 
> > with a corresponding zero-character on a one-to-one basis. 
> > For an example
> > string:
> > 
> > My $string = ' 259.00 ';
> > 
> > Note that I don't want to change the trailing space 
> > character. The resulting string would look like:
> > 
> > '0259.00 '
> 
> How about
> 
> s/ (?=.*\d)/0/g;
> 
> Translation: any space with a digit to its right gets replaced with a
> zero.
> 
> -- 
> Mark Thomas 

Mark,

I also like your solution, thanks!

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Replace Leading Spaces

2006-04-07 Thread Dirk Bremer

> -Original Message-
> From: Arms, Mike [mailto:[EMAIL PROTECTED] 
> Sent: Friday, April 07, 2006 11:37
> To: Perl-Win32-Users@listserv.ActiveState.com
> Cc: Dirk Bremer
> Subject: RE: Replace Leading Spaces
> 
> Dirk Bremer [Dirk.Bremer AT nisc.coop] wrote:
> > Using a regex, I want to replace each leading space-character with a
> > corresponding zero-character on a one-to-one basis. For an example
> > string:
> > 
> >   my $string = ' 259.00 ';
> > 
> > Note that I don't want to change the trailing space character. The
> > resulting string would look like:
> > 
> > '0259.00 '
> > 
> > The total length of the string would remain the same after the
> > replace operation.
> 
> Hi, Dirk,
> 
> You mean something like this?
> 
>   $string =~ s/^(\s+)(?=\d)/'0'x(length $1)/e; 
> 
> The power of the 'e' modifier on the substitution function. :-)
> 
> --
> Mike Arms
> 

Now that one is pretty darn cool and something I didn't know about.
Thanks Mike!

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop  

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Replace Leading Spaces

2006-04-07 Thread Dirk Bremer

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Dirk Bremer
> Sent: Friday, April 07, 2006 09:52
> To: Perl-Win32-Users@listserv.ActiveState.com
> Subject: Replace Leading Spaces
> 
> Using a regex, I want to replace each leading space-character with a
> corresponding zero-character on a one-to-one basis. For an example
> string:
> 
> My $string = ' 259.00 ';
> 
> Note that I don't want to change the trailing space character. The
> resulting string would look like:
> 
> '0259.00 '
> 
> The total length of the string would remain the same after the replace
> operation.
> 
> I'm just having a total brain-fade on this one.
> 

All right, in the mean time, I have come up with the following:

while (s/\s(?=(\d|\.))/0/) {}

This works nicely, but I' wondering if it can be accomplished without
looping and perhaps more efficiently as well.

Your thoughts?

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Replace Leading Spaces

2006-04-07 Thread Dirk Bremer
Using a regex, I want to replace each leading space-character with a
corresponding zero-character on a one-to-one basis. For an example
string:

My $string = ' 259.00 ';

Note that I don't want to change the trailing space character. The
resulting string would look like:

'0259.00 '

The total length of the string would remain the same after the replace
operation.

I'm just having a total brain-fade on this one.

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Reg Expression Help

2006-03-23 Thread Dirk Bremer
 Try '^[\[\]a-zA-Z0-9-_. ]+$' 

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop 

 




From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Scott Purcell
Sent: Thursday, March 23, 2006 14:05
To: Perl-Win32-Users@listserv.ActiveState.com
Subject: Reg Expression Help



Hello,

I have a regular expression in which I am ensuring the user
enters some valid characters for our system.

Currently the expression is so:

'^[a-zA-Z0-9-_. ]+$'

Meaning, a user can enter a-z or A-Z or 0-9, dashes, underbars
or periods and space. 

 

I have a problem now, because they actually are going to allow
users to enter a '[' or a ']' This is stumping me. How can I incorporate
the possibility of having a [ or ] in the user input?

 

 

Thanks,

Scott

 

 


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Testing for Directories

2006-02-08 Thread Dirk Bremer
It turns out that in a very long pathname that I had one-byte that was
incorrect that was causing the file-test -d operator to fail, rightly
so. My mistake! 

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Dirk Bremer
> Sent: Wednesday, February 08, 2006 11:14
> To: perl-win32-users@listserv.ActiveState.com
> Subject: Testing for Directories
> 
> What is the easiest method to detect whether or not a 
> directory exists?
> I will need to create the directory/subdirectory if it is not already
> present. The file test -d does not seem to do the trick. Is there a
> quick and low-overhead method of doing this without actually trying to
> open the directory first? 
> 
> Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake 
> St. Louis MO
> - USA Central Time Zone
> 636-755-2652 fax 636-755-2503
> 
> [EMAIL PROTECTED]
> www.nisc.coop
> 
> ___
> Perl-Win32-Users mailing list
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Testing for Directories

2006-02-08 Thread Dirk Bremer
What is the easiest method to detect whether or not a directory exists?
I will need to create the directory/subdirectory if it is not already
present. The file test -d does not seem to do the trick. Is there a
quick and low-overhead method of doing this without actually trying to
open the directory first? 

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Net::SMTP Question

2006-02-03 Thread Dirk Bremer
> Dirk Bremer wrote:
> > Note the loop as shown above. What am I doing wrong? Do I 
> need to create
> > a new SMTP object for each message? 
> 
> You have to start each message transaction with the "MAIL FROM" SMTP 
> command (i.e. $smtp->mail() ).  You do not need to reconnect 
> unless the 
> server kicks you out after sending an email (some do!).
> 
> You might want to revise your code to something like:
> 
> use Net::SMTP;
> $smtp = Net::SMTP->new('mailhost');
> 
> # start loop
>  # Loop over the following for each message
>  $smtp->mail($ENV{USER});  # <-- Start with this every time!
>  $smtp->to('postmaster');
>  $smtp->data();
>  $smtp->datasend("To: postmaster\n");
>  $smtp->datasend("\n");
>  $smtp->datasend("A simple test message\n");
>  $smtp->dataend();
> # end loop
> 
> $smtp->quit;
> # EOF

DZ-Jay wins the Friday's Best Answer Award for this week. I have many
programs that send single email messages, but none that needed to send
multiple until now. His advice as stated above worked perfectly. The
documentation for Net::SMTP is rather sparse and doesn't address this
situation. DZ-Jay has his choice of a virtual-6-pack or a virtual bottle
of reserve for his great response. 

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Net::SMTP Question

2006-02-03 Thread Dirk Bremer
I have a need to send multiple email messages within a single instance
of a program. I have a problem where the first composed email message is
sent (and received) okay, while the subsequent messages are not. The
code is similar to this:

use Net::SMTP;
$smtp = Net::SMTP->new('mailhost');
$smtp->mail($ENV{USER});

# Loop over the following for each message
$smtp->to('postmaster');
$smtp->data();
$smtp->datasend("To: postmaster\n");
$smtp->datasend("\n");
$smtp->datasend("A simple test message\n");
$smtp->dataend();

$smtp->quit;

Note the loop as shown above. What am I doing wrong? Do I need to create
a new SMTP object for each message? 

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Classes as modules?

2006-01-12 Thread Dirk Bremer
I have all of the modules that I have created either in the same single
directory that contains the scripts or in sub-directories of the script
directory. I use this in every script:

use FindBin qw($Bin);
use lib $Bin;

I never have any problems no matter where the script is executed from.
Hope this helps.

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop 

> Yes, I will have to calculate the path, since it is not absolute.
> 
> If I put a relative path in @INC, I guess it would be relative to the 
> current directory.  Which is whatever the directory the console is in 
> when it runs the script.  Not very useful for finding 
> modules.  Instead 
> I want to find a path relative to where the script is located.  
> (Actually, I'm interested in finding the parent directory of the one 
> where the script is located.)  As far as I can tell, there is no 
> function that tells me that.  That is why I have to calculate it.
> 
> I suppose putting the path determination stuff in a function, and 
> putting a pointer to that in @INC would work.  I guess I just felt 
> skiddish about it because it seems unusual.
> 
> What is the most common way that people handle this?  That 
> is, say your 
> modules are in the same folder as the main script.  (Which I 
> would think 
> would be the most common case, except for CPAN or PPM modules.)  Do 
> people usually write a function to determine where the script is 
> located?  You'd think there would be a common function for this
> 
> My code currently handles it is below, which seems incredibly obtuse, 
> but I couldn't figure a simpler reliable way.  That is the 
> code I'd have 
> to pass in as a function to @INC (except with 'return' 
> instead of 'chdir').
> 
> # determine V-ASC installation directory 
> ---
> #-- it is the parent directory of where this file is run from
> 
> my ($VAscVolume,$ServerPath) =
>   File::Spec->splitpath(File::Spec->rel2abs($0));
> my @ServerDirs = File::Spec->splitdir($ServerPath);
> my $VAscPath = File::Spec->catdir(@[EMAIL PROTECTED]);
> my $VAscInstallDir
>   = 
> File::Spec->canonpath(File::Spec->catpath($VAscVolume,$VAscPath,''));
> my $VAscServerDir
> = 
> File::Spec->canonpath(File::Spec->catpath($VAscVolume,$ServerP
> ath,''));
> 
> chdir $VAscInstallDir;
> 
> -- 
> Lyle Kopnicky
> Software Project Engineer
> Veicon Technology, Inc.

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Daylight Savings Time

2005-10-31 Thread Dirk Bremer
> -Original Message-
> From: David Dick [mailto:[EMAIL PROTECTED] 
> Sent: Monday, October 31, 2005 14:57
> To: Dirk Bremer
> Cc: perl-win32-users@listserv.ActiveState.com
> Subject: Re: Daylight Savings Time
> 
> Dirk Bremer wrote:
> > I check certain files' modification dates against a 
> modification date
> > stored in a database for the corresponding file. The files were not
> > modified since they were entered into the database, i.e. the dates
> > should have been equal. At about 01:00 on 10-30-2005, 
> things were a bit
> > different. For example, the date stored in the database was 
> 2005-10-17
> > 14:28:10, while after the time changed, the date returned 
> was 2005-10-17
> > 13:28:10, an exact one-hour difference. The modification date was
> > obtained from stat. This did cause some problems.
> 
> i'm guessing you're storing dates in localtime? is it 
> possible for you 
> to store the dates in gmtime and display in localtime?
> 
> uru
> -Dave
>

Dave & $Bill,

Yes, it looks like using epoch-time is the way to go. I'll need to add a
new column to the database table and then modify a few programs so I can
store and compare the modification date as an epoch-time interval.
Thanks for the suggestion.

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop 
 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Daylight Savings Time

2005-10-31 Thread Dirk Bremer
What, nobody else had a daylight savings time change issue? Well, I sure
did.

I check certain files' modification dates against a modification date
stored in a database for the corresponding file. The files were not
modified since they were entered into the database, i.e. the dates
should have been equal. At about 01:00 on 10-30-2005, things were a bit
different. For example, the date stored in the database was 2005-10-17
14:28:10, while after the time changed, the date returned was 2005-10-17
13:28:10, an exact one-hour difference. The modification date was
obtained from stat. This did cause some problems.

I guess that ideally, the program which performs these comparisons would
be aware of when the time changes twice a year to and from daylight
savings time and would adjust the returned modification dates. The issue
is how to identify within a Perl program the time changes. Note that
this action is occurring on Windows-based servers and if I examine the
file in the above example's modification date using Windows Explorer, it
is reported as 2005-10-17 13:28:10.

To compound this, I have heard that the time-change schedule would be
changed in 2006 so that DST would start 2-weeks earlier and end 1-week
later.

Is there a way to determine DST changes in Perl through a module, etc.?
Or would one have to manually account for the DST schedule every year? 

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Variable definition

2005-10-07 Thread Dirk Bremer



$month = '07';
Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. 
Louis MO - USA Central Time Zone636-755-2652 fax 
636-755-2503[EMAIL PROTECTED]www.nisc.coop 
 

  
  
  From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On Behalf Of 
  Pierce, Glen ESent: Friday, October 07, 2005 
  08:35To: 
  perl-win32-users@listserv.ActiveState.comSubject: Variable 
  definition
  
  
  This may seem like a simple 
  question, but I have a variable $month=7 but I want to represent it as 
  $month=07.  How is this done.  I am not sure what to search on to 
  find out how to do this, hence I am here.
  Thanks in 
  advance,
  Glen.
   
  The Home 
  Depot
  2455 Paces Ferry 
  Rd
  Atlanta 
  30339
   
  What do you call a boomerang that does not come back 
  ?  A stick.
   
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: how to interact with an endless loop

2005-10-06 Thread Dirk Bremer
seconds and try
again.
unless($Socket) {sleep(10); next}

# Process the connection.
while ()
{
# Prompt the user for a command string.
print("\nEnter command string>");
$_ = ;
chomp;

# Exit this program based upon user input.
last SOCKET if ($_ eq 'exit');

# Write the entered command to the socket connection.
print($Socket "$_\n");

# Wait for and then process the information returned from the
server.
while ($Answer = <$Socket>)
{
chomp($Answer);
    print("Accepted from server: $Answer\n");

# Exit this loop when the server replies that the submitted
# command has completed.
last if ($Answer eq 'command complete');
}

# Exit the socket connection if a end of terminate command was
entered.
last SOCKET if ($_ eq 'term' or $_ eq 'end');
}
}
# Close the socket connection.
close($Socket);

exit(1);

__END__

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Check for running process

2005-09-20 Thread Dirk Bremer
Here is another example by searching for the actual program-name in the
process-list:

use Win32::OLE qw(in);
use Win32::OLE::Variant;

# Find all PIDs, program-names, and executable paths for all running
processes.
for my $Process (sort{lc($a->{Name}) cmp lc($b->{Name})} in
($WMI->InstancesOf("Win32_Process")))
{
$Name = $Process->{Name};   # Process program-name.
$Path = $Process->{ExecutablePath}; # Process executable path.
$PID  = $Process->{ProcessID};  # PID.
$Path = '' unless (defined($Path));

# Search for the PIDs for specific program-names.
if ($Name =~ /acrobat\.exe/i) {$Acrobat = $PID}
if ($Name =~ /acrotray/i) {$Tray= $PID}
if ($Name =~ /monitor\.exe/i) {$Monitor = $PID}
}

# Kill Acrobat if it is running.
if ($Acrobat) {kill('STOP',$Acrobat)}

# Kill Acrotray if it is running.
    if ($Tray) {kill('STOP',$Tray)} 
 

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop 

 




From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Darrell Snedecor
Sent: Tuesday, September 20, 2005 08:47
To: perl-win32-users@listserv.ActiveState.com
Subject: Check for running process


How do I use Perl to check for the existence of a running
program in Windows?
 
 
Best Regards
Darrell Snedecor
Director
Harrisburg Project
800-635-5274  618-253-8504
 


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Check for running process

2005-09-20 Thread Dirk Bremer
Here is one way by searching for a window-name in the variable $Program:

# Check for another instance of this program.
use Win32::GUI;
my $Desktop = GUI::GetDesktopWindow();
my $Window  = GUI::GetWindow($Desktop, GW_CHILD);
my $Nbr = 0;
# $Program= ($HostName eq 'mailcd3') ? 'SchedulePDF' :
'ArchivePDF';
$Program= 'ArchivePDF';
while ($Window)
{
my $Title  = GUI::Text($Window);
if (length($Title) > 1 and $Title !~ /command prompt/i) {$Nbr++
if ($Title =~ /^$Program/i)}
$Window = GUI::GetWindow($Window, GW_HWNDNEXT);
}

if ($Nbr > 1)
{
print(STDERR "Another instance of this program exists, exiting
program\n");
print(STDERR "Ending $0\n");
exit(1);
}
 
In this example, if an instance of this program is already running, we
will exit the program to prevent multiple occurences of the program.
Note that in this example, we are searching against the window's actual
title.  

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop 

 




From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Darrell Snedecor
Sent: Tuesday, September 20, 2005 08:47
To: perl-win32-users@listserv.ActiveState.com
Subject: Check for running process


How do I use Perl to check for the existence of a running
program in Windows?
 
 
Best Regards
Darrell Snedecor
Director
Harrisburg Project
800-635-5274  618-253-8504
 


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: cron for windows ???

2005-08-24 Thread Dirk Bremer
Michael,

I use the WS (Windows Scheduler) extensively on several machines many
times daily. I have scripts that run every 15 minutes, 30 minutes,
hourly, daily, monthly, etc. I find I get the best mileage from creating
a batch-file that contains the execution of the program and its
parameters and then have the WS call the batch-file. I will sometimes
abstract this a little farther for logging purposes by having the WS
call a batch-file (parent) that calls another batch-file (child). The
contents of the parent would look something like this:

C:\Batch_Files\DailyTasks_Stub.bat 1>C:\Temp\DailyTasks.log 2>&1
exit 1

This way I can redirect the output of the entire child batch-file to a
single log-file and group multiple programs/tasks in the child
batch-file.

Note you can specify a context for the job to start in, i.e. a specific
directory, in the properties of the scheduled task. Also, you will need
to set the appropriate password for the task. One special note on
passwords, if you change the password of the machine that will schedule
the tasks, you will need to also go into the scheduled tasks and change
the passwords of each task. There may be a way around this, but I am
unaware of how to do this otherwise. We change passwords on a regular
basis, so this comes into play for us. You might also try specifying
full path/UNC-names for everything, including Perl, the Perl script,
etc.:

C:\perl\bin\perl.exe C:\somedirectory\yourprogram.pl "arguments"

Note that when paths/filenames are specified that contain embedded
spaces, its best to enclose the entire string in quotation marks, i.e.:

C:\perl\bin\perl.exe C:\somedirectory\yourprogram.pl "c:\program
files\test\some log file directory\log.txt"

Let me know if you need any other specifics.

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Michael D Schleif
Sent: Wednesday, August 24, 2005 10:51
To: perl-win32-users mailing list
Subject: cron for windows ???

We have a script that runs as expected from CLI.  Basically, it parses
logfiles, and prepends to another logfile one line of summary.  Very
basic, very simple stuff.

We want it to run once per day at a specified time.  It runs on a
Windows Server 2003 box.  Windows Scheduler is very flaky on this box --
sometimes it runs the script, sometimes not.  When it does run the
script, it runs as expected.

I have googled for cron implementations for windows, and I found these:
- cronw <http://sourceforge.net/projects/cronw>
- cron  <http://www.kalab.com/freeware/cron/cron.htm>

Clearly, these are two completely different implementations, one Perl
and the other compiled.  Both fail to successfully run our script,
apparently failing for same reasons.

Unfortunately, I do not understand why the code succeeds from CLI and
fails from these cron's.  Here is the first point of breakage in the
code:

-f $out_file
or die "\n\tERROR: *NOT* a file: \'$out_file\'\n\n";

I have simplified this, with same failure:

-f $out_file and die;

Earlier code defines:

my $out_dir = "P:/Backup";
my $out_file = "Tape_Slot.log";
$out_file = $out_dir . '/' .  $out_file;

Yes, I am aware of issues with forward & backward slashes; and issues
with single & double quotes.  No, I have NOT found any combination of
these characters that allow cron to successfully execute this code.
Also, remember, the existing code runs exactly as expected from CLI.

I will gladly publish more code, and try suggestions, if requested.  At
this point, I am trying to present the succinct case, and plead for your
kind assistance.

What do you think?

-- 
Best Regards,

mds
mds resource
877.596.8237
-
Dare to fix things before they break . . .
-
Our capacity for understanding is inversely proportional to how much
we think we know.  The more I know, the more I know I don't know . . .
--

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Measure bandwidth

2005-05-24 Thread Dirk Bremer
Eric,
 
Here is an example of a subroutine that I use:
 
sub CopyFile($$)
{
# Accept arguments.
my $Source = shift;
my $Target = shift;

# Declare local variables.
local $_;
my $Length = 0;
my $Size = -s $Source;
 
unless (defined($Size) and $Size > 0)  {$Log->WriteLog("*** Source
$Source has a zero file-size ***",0); close(FH1); return(0)}
my $Buffer = ($Size < 8388608) ? $Size : 8388608;
unless (open(FH1,"<$Source"))  {$Log->WriteLog("*** Unable
to open Source $Source $! ***",0); return(0)}
unless (flock(FH1, LOCK_EX | LOCK_NB)) {$Log->WriteLog("*** Source
$Source cannot be locked ***",0);  close(FH1); return(0)}
unless (open(FH2,">$Target"))  {$Log->WriteLog("*** Unable
to open Target $Target $! ***",0); return(0)}
unless (flock(FH2, LOCK_EX | LOCK_NB)) {$Log->WriteLog("*** Target
$Target cannot be locked ***",0);  close(FH2); return(0)}
binmode(FH1);
binmode(FH2);
$Log->WriteLog("$Source is copying to $Target",0);
while (read(FH1,$_,$Buffer)) {$Length += length(); print(STDERR
Nisc::ProgressBar($Length,$Size,50,'=')); print(FH2)}
print(STDERR "\n");
close(FH1);
close(FH2);
utime(time,time,$Target);
$Log->WriteLog(join('
','Input-file-size:',$Size,'Output-file-size:',-s $Target),0) if (-e
$Target);
return(1);
}

Note that there is a little line-wrapping in this message. Some notes:

1. $Log->WriteLog is a module that simply writes the supplied textual
argument to STDERR and a filehandle. You may substitute a print function
for $Log->WriteLog.

2. Nisc::ProgressBar is an adaptation of some nifty code that someone
else wrote:

sub ProgressBar()
{
my ($Got,$Total,$Width,$Char) = @_;
$Width ||= 25;
$Char  ||= '=';
my $NumWidth = length $Total;
sprintf("|%-${Width}s| Got %${NumWidth}s bytes of %s
(%.2f%%)\r",$Char x
(($Width-1)*$Got/$Total).'>',$Got,$Total,100*$Got/+$Total);
}

3. I'm not sure about File::Copy, I'll have to have a look at it.  

Dirk Bremer - Systems Programmer II - ESS/AMS - NISC Lake St. Louis MO -
USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop 

 


From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Eric Logeson
Sent: Tuesday, May 24, 2005 12:15
Cc: perl-win32-users@listserv.ActiveState.com
Subject: Re: Measure bandwidth


    Thanks Dirk
Some good tips there, I will have to add file deletion routine.
 
regarding point 5 below, would file::copy be shell based?

 
On 5/24/05, Dirk Bremer <[EMAIL PROTECTED]> wrote: 

Eric,

I can only offer some general advice. I do something
similar to get
statistics on FTP-transfers. Here are some notes: 

1. Since I have multiple events (2 per transfer, i.e.
start and end
times) and multiple transfers per session, I define an
array to hold the
various times, i.e. @Time.

2. For each event, push(@Time,time); 

3. To calculate the elapsed time and transfer rate,
where $PDF_File and
$SNI_File contain the filenames of the respective files
and the first
time argument is the end-time, the second time argument
is the
start-time:

   # Calculate usage statistics.
   my ($PDF_Time, $PDF_Rate) =
@{Stats($PDF_File,$Time[1],$Time[0])};
   my ($SNI_Time, $SNI_Rate) =
@{Stats($SNI_File,$Time[3],$Time[2])};

4. The subroutine that calculates the statistics: 


#---
---#
# Compute transfer statistics.
#

#---
---#
sub Stats($$$) 
{
   my $File= shift;
   my $Time1   = shift;
   my $Time2   = shift;
   my $Hours   = 0;
   my $Minutes = 0;
   my $Time= $Time1 - $Time2;
   my $Size= -s $File;
   my $Rate = $Size; 
   if ($Time > 0) {$Rate = sprintf('%2.2f',$Size /
$Time)}
   $Rate = sprintf('%2.2f',($Rate / 1024));
   $Log->WriteLog("File:  $File",0);
   $Log->WriteLog("Time1: $Time1",0); 
 

RE: Measure bandwidth

2005-05-24 Thread Dirk Bremer
Eric,

I can only offer some general advice. I do something similar to get
statistics on FTP-transfers. Here are some notes:

1. Since I have multiple events (2 per transfer, i.e. start and end
times) and multiple transfers per session, I define an array to hold the
various times, i.e. @Time.

2. For each event, push(@Time,time);

3. To calculate the elapsed time and transfer rate, where $PDF_File and
$SNI_File contain the filenames of the respective files and the first
time argument is the end-time, the second time argument is the
start-time:

# Calculate usage statistics.
my ($PDF_Time, $PDF_Rate) = @{Stats($PDF_File,$Time[1],$Time[0])};
my ($SNI_Time, $SNI_Rate) = @{Stats($SNI_File,$Time[3],$Time[2])};

4. The subroutine that calculates the statistics:

#---
---#
# Compute transfer statistics.
#
#---
---#
sub Stats($$$)
{
my $File= shift;
my $Time1   = shift;
my $Time2   = shift;
my $Hours   = 0;
my $Minutes = 0;
my $Time= $Time1 - $Time2;
my $Size= -s $File;
my $Rate = $Size;
if ($Time > 0) {$Rate = sprintf('%2.2f',$Size / $Time)}
$Rate = sprintf('%2.2f',($Rate / 1024));
$Log->WriteLog("File:  $File",0);
$Log->WriteLog("Time1: $Time1",0);
$Log->WriteLog("Time2: $Time2",0);
$Log->WriteLog("File Time: $Time",0);
$Log->WriteLog("File Size: $Size",0);
$Log->WriteLog("File Rate: $Rate",0);
my $Seconds = $Time;
if ($Time > 3600) {$Hours   = sprintf('%d',$Time / 3600); $Time
= $Time % 3600}
if ($Time > 60)   {$Minutes = sprintf('%d',$Time / 60);   $Seconds
= $Time % 60}
$Time =
join(':',Lpad($Hours,'0',2),Lpad($Minutes,'0',2),Lpad($Seconds,'0',2));
$Log->WriteLog("File Time: $Time",0);
return([$Time,$Rate]);
}

Note that the above subroutine was designed in mind for transfers that
take less than 24-hours, for transfers that would take longer than that,
some other date/time manipulations may be required.

5. You will probably want to write your own Perl subroutine to actually
perform the copying rather than using the sheel-based copy command as
the overhead of spawn a shell-command may be unpredictable.

6. You might consider deleting each file first if it exists as their
might be less overhead involved in copying over an existing file.

7. There may be other things that I haven't considered.

Dirk Bremer - Systems Programmer II - ESS/AMS - NISC Lake St. Louis MO -
USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop 

_

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Eric Logeson
Sent: Tuesday, May 24, 2005 10:28
To: perl-win32-users@listserv.ActiveState.com
Subject: Measure bandwidth


Hello List
 
I wanted to get some basic bandwidth statistics across a WAN
link.  The approach I think I am going to take is the following:
Use a perl scipt to read in a bunch of files, determine the
sizes, start a timer (not sure how to do this yet), copy the files
across the link (winxp->win2003 server), stop the timer,
and finally write out the bytes/sec metric to a log file.  I
planned on scheduling the perl script to run every hour or so for a
week.
 
Are there modules of interest for this project.  Any suggestions
on the approach?
 
 
Thanks
Eric


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Filename pull

2005-04-21 Thread Dirk Bremer
Here's some interesting results:

#! C:/perl/bin/perl -w
use diagnostics;
use strict;
use warnings;

use Benchmark;
my $str = 'C:\Program
Files\Oracle\Inventory\Components21\oracle.swd.jre\1.1.8.16.0\resources\
CompID.properties';
timethese(0,{'regex' => sub {$str =~ /\\([\w\._-\s]+)$/g; return($1)},
 'split' => sub {return((split(m![\\/]!,$str))[-1])},
 'parse' => sub {my ($Fe, $Fn, $Fp, $Pos1, $Pos2);
 $Pos1 = rindex($str,(index($str,'/') > -1)
? '/' : '\\');
 $Pos2 = rindex($str,'.');
 if ($Pos1) {$Pos1++; $Fp =
substr($str,0,$Pos1)} else {$Fp = undef; $Pos1 = 0}
 if ($Pos2) {$Fn = substr($str,$Pos1,$Pos2 -
$Pos1); $Pos2++; $Fe = substr($str,$Pos2)}
 else {$Fn = substr($str,$Pos1); $Fe =
undef}
 return(($Fp,$Fn,$Fe))}});

c:\temp>regex
False [] range "_-\s" before HERE mark in regex m/\\([\w\._-\s << HERE
]+)$/ at C:\Perl\Scripts\regex.pl line 8.
Benchmark: running parse, regex, split, each for at least 3 CPU
seconds...
 parse:  4 wallclock secs ( 3.26 usr +  0.00 sys =  3.26 CPU) @
140179.17/s (n=457685)
 regex:  4 wallclock secs ( 3.00 usr +  0.00 sys =  3.00 CPU) @
141003.66/s (n=423575)
 split:  4 wallclock secs ( 3.08 usr +  0.00 sys =  3.08 CPU) @
83444.55/s (n=257343)

Note the 'parse' subroutine's performance and the fact that it will
return the path, the leafname, and the extension of the supplied
filename.

One of my questions would be would the regex used in the 'regex' and
'split' subroutines cover every circumstance and always return the
correct results? I don't know. I developed the 'parse' code a while back
to use on Windows platforms, although because it determines the
delimiter character, i.e. / or \, it might work on *nix platforms as
well. If anyone can get more performance out of any of these three
subroutines or can offer one that will do better, I would like to know. 

-Original Message-
From: Dirk Bremer 
Sent: Thursday, April 21, 2005 16:37
To: '[EMAIL PROTECTED]'; Chad I. Uretsky
Cc: [EMAIL PROTECTED];
'activeperl@listserv.ActiveState.com'
Subject: RE: Filename pull

Anthony,
 
I tried your regex example out of curiosity:
 
my $str = 'C:\Program
Files\Oracle\Inventory\Components21\oracle.swd.jre\1.1.8.16.0\resources\
CompID.properties';
$str =~ /\\([\w\._-\s]+)$/g;
print(">$1<\n"); 

While it does produce the correct result in this instance, it also
produces a warning:
 
c:\temp>regex
False [] range "_-\s" before HERE mark in regex m/\\([\w\._-\s << HERE
]+)$/ at C:\Perl\Scripts\regex.pl line 7.
>CompID.properties<





From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Thursday, April 21, 2005 15:54
To: Chad I. Uretsky
Cc: [EMAIL PROTECTED];
'activeperl@listserv.ActiveState.com'
Subject: RE: Filename pull



To add to Chad's last email, the following will cater for spaces
and special (allowed) characters in the file name 

$s1 = "c:\\temp\\bola\\temilola\\abolan-lef o_o.pl"; 
  
$s1 =~/\\([\w\._-\s]+)$/g; 

print $1; 

Tony B. Okusanya
Distributed Technology Group


"Live Life By Design And Not From Crisis to Crisis" 



"Chad I. Uretsky" <[EMAIL PROTECTED]> 
Sent by: [EMAIL PROTECTED] 

04/21/2005 03:03 PM 


To
"'activeperl@listserv.ActiveState.com'"
 
cc

Subject
RE: Filename pull






try: 
  
$s1 = "c:\\temp\\foo.pl"; 
  
$barename = ($s1 =~ /\\(\w+\.\w+)$/)[0]; 
  
  
  
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Thursday, April 21, 2005 1:59 PM
To: activeperl@listserv.ActiveState.com
Subject: Filename pull


Hey, wizards. 

I've got this problem: pulling the bare filename off of a fully
pathed string, using split. The tricky part is getting the last element
in the array when I don't know how many members are in it. Example: 

$s1 = "c:\\temp\\foo.pl"; 
$barename = (split( /\\/, $s1)[2];  # $barename gets "foo.pl" 

Now obviously this works as far as it goes, but what

RE: Windows Tasks

2005-04-14 Thread Dirk Bremer
Title: Message



Stuart,
 
Thanks for all of the advice. In this particular instance, I have 
none of the concerns you raise as this is a very specialized and simple 
program/interface. I can well imagine the possible complexities present in mode 
standard Windows applications.

  
  
  From: stuart arnold 
  [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 13, 2005 
  22:56To: Dirk Bremer; 
  Perl-Win32-Users@listserv.ActiveState.comSubject: RE: Windows 
  Tasks
  
  Dirk,
  Some other things 
  to watch out for when working with manipulating windows:
   
  1) Watchout for 
  languages. "File->Open" change in other languages. Don;t always depend on 
  the text.
   
  2) Check the ver# 
  of the app! using IDs to execute the command is good/safe, but, you may 
  need
  to check the s/w 
  ver# of the app.  Good example is that "Notepad" on XP and NT have 
  different IDs on some commands.
  (and we thought it 
  was an old product!)
   
  3) Watch out that 
  some apps let the user customize menus, keys, etc.  They may change what 
  you think is OK for a SendKey, and then they've changed 
it.
   
  There are a lot 
  more gotcha's when working with windows.  I've been doing this same type 
  of stuff for quite some time.
   
  HTH.
  -stuart
   
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Windows Tasks

2005-04-13 Thread Dirk Bremer
Bill and Stuart,

I ended up with a working program that does this:

1. Find all programs and their PIDs using WMI from within Perl.
2. Kill certain programs using the PIDS derived above.
3. Starting a new instance of the program with Win32::Process, although
I feel at this point that it is not a requirement to start the program
this way, i.e. it could just as easily be started with the system
command. I don't fee that Win32::Process buys me anything at this point.
4. Find the instance of the program using Win32::GuiTest.
5. Send a button press to the appropriate button using Win32::GuiTest.

Win32::GuiTest absolutely rules! It was so simple to use and worked just
as I wanted right out of the box. Note that there was HTML file
generated for the Win32::GuiTest ppm, so I gleaned some information on
its usage from the POD embedded in the source.

To Bill's comment, I'm not sure that obtaining the PID of the process
started by Win32::Process would help with anything here. I could not
divine that the PID could be supplied as an argument to any of the
Win32::GuiTest functions.

For those that may be interested in something like this, I'll be happy
to post the code.


-Original Message-
From: $Bill Luebkert [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 13, 2005 13:45
To: Dirk Bremer
Cc: Perl-Win32-Users@listserv.ActiveState.com
Subject: Re: Windows Tasks

Dirk Bremer wrote:

> Stuart,
> 
> I've managed to program items 1-3 using Win32::OLE and WMI. For item
4,
> I can start the program in various ways, i.e. system, Win32::Process,
> etc.
> 
> I'm not sure that the program in question allows any key-presses, I
> tested it and could not find a way other than using the mouse to
> activate the Start button.
> 
> I did use WinSpector to find out the Start buttons control-ID.
> 
> So at this point, I need the best method to start the program and
> activate the Start button. Is your reference to 'FindWindow' something
> other than a generic description of the method I am using to find the
> processes or something else, and if something else, specifically what?
> Once the program is running, how do I send a message to the program to
> activate the Start button?

I would think that if you used Win32::Process to start the process,
you would have the advantage of already knowing the pid of the process
using $process->GetProcessID.  What about using the SendMouse command
in Win32::GuiTest ?

-- 
  ,-/-  __  _  _ $Bill Luebkert
Mailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--<  o // //  Castle of Medieval Myth & Magic
http://www.todbe.com/
-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Windows Tasks

2005-04-13 Thread Dirk Bremer
Stuart,

I've managed to program items 1-3 using Win32::OLE and WMI. For item 4,
I can start the program in various ways, i.e. system, Win32::Process,
etc.

I'm not sure that the program in question allows any key-presses, I
tested it and could not find a way other than using the mouse to
activate the Start button.

I did use WinSpector to find out the Start buttons control-ID.

So at this point, I need the best method to start the program and
activate the Start button. Is your reference to 'FindWindow' something
other than a generic description of the method I am using to find the
processes or something else, and if something else, specifically what?
Once the program is running, how do I send a message to the program to
activate the Start button?
 

-Original Message-
From: stuart arnold [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 13, 2005 12:05
To: Dirk Bremer; Perl-Win32-Users@listserv.ActiveState.com
Subject: RE: Windows Tasks

Since you started it with that way, you can use the GuiTest::SendKeys()
to actually simulate the user key press events, eg, if you started
"Notepad" and want to activate the "File->Open", then you could invoke
SendKeys( '%fo' );
See more on Win32::GuiTest.  

As far as getting the WindowHandle of the process, you'll probably want
to re-invoke 'FindWindow' on the window you just launched (processes can
have multiple windows).
That said, you'll have the hwnd of it and can do as you please.

On to the BETTER question you asked: How do I get control IDs.
There are 2 apps you can use, both free: SPY++ and WinSpector.
I prefer Winspector: http://www.windows-spy.com/

Good luck!

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Dirk Bremer
Sent: Wednesday, April 13, 2005 11:46 AM
To: Perl-Win32-Users@listserv.ActiveState.com
Subject: RE: Windows Tasks


Stuart,

For your suggestion on item 5, where would I get the window handle from?
By using Win32::Process to start the process? The program in question is
a third-party vendor's provided program, so how would I go about
determining the ID of the control or menu item? Note that this
application does not have a menu, just four buttons.   

-Original Message-
From: stuart arnold [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 13, 2005 10:38
To: Dirk Bremer; Perl-Win32-Users@listserv.ActiveState.com
Subject: RE: Windows Tasks


For item #3: since you have the window handle (from FindWindow), just do
a SendMessage() with WM_CLOSE.

For item #5: You probably have the window handle to the started process.
You can do a SendMessage on that for the command, ie, "Start" button.
You'll need the ID of the control or menu item to do that.
HTH
-----Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Dirk Bremer
Sent: Wednesday, April 13, 2005 10:44 AM
To: Perl-Win32-Users@listserv.ActiveState.com
Subject: Windows Tasks

I have the requirement to write a Perl program that will accomplish the
following tasks:
1. Identify if process X is running.
2. If process X is not running, check if Acrobat is running.
3. If Acrobat is running, kill it.
4. Start a new instance of process X.
5. Once the instance of process X starts, press the Start button on the
process X window.
I can perform item 1 using Win32::GUI to search for the window title. 
I could use the same technique for item 2. 
I do not know how to perform item 3.
I can perform item 4.
I do not know how to perform item 5.
The window title for process X is static and known ahead of time. I also
know the actual program executable name. The same is also know from
Acrobat.
Your suggestions will be appreciated.
Dirk Bremer - Systems Programmer II - ESS/AMS - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471
[EMAIL PROTECTED]
www.nisc.cc 
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Windows Tasks

2005-04-13 Thread Dirk Bremer
Stuart,

For your suggestion on item 5, where would I get the window handle from?
By using Win32::Process to start the process? The program in question is
a third-party vendor's provided program, so how would I go about
determining the ID of the control or menu item? Note that this
application does not have a menu, just four buttons.   

-Original Message-
From: stuart arnold [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 13, 2005 10:38
To: Dirk Bremer; Perl-Win32-Users@listserv.ActiveState.com
Subject: RE: Windows Tasks


For item #3: since you have the window handle (from FindWindow), just do
a SendMessage() with WM_CLOSE.

For item #5: You probably have the window handle to the started process.
You can do a SendMessage on that for the command, ie, "Start" button.
You'll need the ID of the control or menu item to do that.
HTH
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Dirk Bremer
Sent: Wednesday, April 13, 2005 10:44 AM
To: Perl-Win32-Users@listserv.ActiveState.com
Subject: Windows Tasks

I have the requirement to write a Perl program that will accomplish the
following tasks:
1. Identify if process X is running.
2. If process X is not running, check if Acrobat is running.
3. If Acrobat is running, kill it.
4. Start a new instance of process X.
5. Once the instance of process X starts, press the Start button on the
process X window.
I can perform item 1 using Win32::GUI to search for the window title. 
I could use the same technique for item 2. 
I do not know how to perform item 3.
I can perform item 4.
I do not know how to perform item 5.
The window title for process X is static and known ahead of time. I also
know the actual program executable name. The same is also know from
Acrobat.
Your suggestions will be appreciated.
Dirk Bremer - Systems Programmer II - ESS/AMS - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471
[EMAIL PROTECTED]
www.nisc.cc 
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Windows Tasks

2005-04-13 Thread Dirk Bremer
I have the requirement to write a Perl program that will accomplish the
following tasks:

1. Identify if process X is running.
2. If process X is not running, check if Acrobat is running.
3. If Acrobat is running, kill it.
4. Start a new instance of process X.
5. Once the instance of process X starts, press the Start button on the
process X window.

I can perform item 1 using Win32::GUI to search for the window title. 
I could use the same technique for item 2. 
I do not know how to perform item 3.
I can perform item 4.
I do not know how to perform item 5.
The window title for process X is static and known ahead of time. I also
know the actual program executable name. The same is also know from
Acrobat.

Your suggestions will be appreciated.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


PAR

2005-04-05 Thread Dirk Bremer
I installed PAR via ppm but am missing a require module, i.e.:

Can't locate Module/ScanDeps.pm in @INC

I would prefer a PPM-installable version of this missing file is
possible, otherwise I would need instructions on how to install it from
CPAN.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: PAR

2005-04-05 Thread Dirk Bremer

I installed PAR via ppm but am missing a require module, i.e.:

Can't locate Module/ScanDeps.pm in @INC

I would prefer a PPM-installable version of this missing file is
possible, otherwise I would need instructions on how to install it from
CPAN.

And if it makes a difference, I'm using Perl v5.6.1.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Directory browsing in a dialogbox

2005-02-10 Thread Dirk Bremer
Try this:

use Win32::FileOp;

my @Files = Win32::FileOp::OpenDialog(-title   => "Select File(s) to
process",
  -filters => ['All Files' =>
'*.*'],
  -defaultfilter => 1,
  -dir => 'c:\\',
  -filename => '*.*',
  -options => OFN_ALLOWMULTISELECT |
OFN_EXPLORER);


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Thursday, February 10, 2005 14:04
To: Perl-Win32-Users@listserv.ActiveState.com
Subject: Directory browsing in a dialogbox

Hello everybody

When I run my script I want a dialogbox where the user can browse the
directories
on his computer and select a file. The name of the selected file is used
for further processing within the script. I' m thinking about something
similiar
to the directory selection in installation scripts. How can I do this? 

Thanks for your help

Roland

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regex Help

2005-01-27 Thread Dirk Bremer

Yes, my brain was asleep today an forgot to throw in the anchors. The
{0,2} construct is a good idea but not required in this instance as the
field cannot exceed 10-characters. Thanks for everyone's help with this.


-Original Message-
From: Lloyd Sartor [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 27, 2005 11:50
To: [EMAIL PROTECTED]
Cc: Dirk Bremer; perl-win32-users@listserv.ActiveState.com;
[EMAIL PROTECTED]
Subject: RE: Regex Help


The reason that "200412" matches in your first regex is that the first
four characters match the pattern (as expected) but there is nothing in
the regex that causes the additional characters "12" to result in  a
mismatch; the regex engine simply ignores them. Adding "$" to the regex
(as Mike has done) will disallow any additional characters in the
string, and should work as you expected. 

Furthermore, using * instead of {0,2} will match strings such as
2004-12-01-02-03. 




<[EMAIL PROTECTED]> 
Sent by: [EMAIL PROTECTED] 

01/27/2005 11:06 AM 

To:<[EMAIL PROTECTED]>,
 
cc: 
Subject:RE: Regex Help



Dirk,

I'm not a regex pro, but this worked for me: /^\d{4}(-\d{2}){0,2}$/

I tested it with this:

@test = qw(  2004 200412 20041201 2004-12 2004-12-01 );

foreach $test (@test) {
print "$test : " . ($test =~ /^\d{4}(-\d{2}){0,2}$/ ?
"TRUE" : "FALSE") . "\n";
}


Regards,
Mike

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
Dirk Bremer
Sent: Thursday, January 27, 2005 10:43 AM
To: perl-win32-users
Subject: Regex Help



I need to test for the following date-type strings:

2004
2004-12
2004-12-01

All of the above would be legal, any other combination would be illegal.

I have been using the following data to test the regex:

''Should produce a false result.
'2004'Should produce a true result.
'200412'  Should produce a false result.
'20041201'Should produce a false result. 
'2004-12' Should produce a true result.
'2004-12-01'  Should produce a true result.

My first attempt at a regex is /\d{4}(-\d{2})*/. This produces the
following result:

 is false
2004 is true
200412 is true
20041201 is true
2004-12 is true
2004-12-01 is true

I would prefer that '200412' and '20041201' would fail, i.e. be reported
as false. I'm not sure what's going on with this regex as I would expect
the following:

match the first four numeric characters, then match zero
or more
occurrences of a dash character followed by two numeric characters

The next regex /\d{4}(-\d{2})+/ produces the following results:

 is false
2004 is false
200412 is false
20041201 is false
2004-12 is true
2004-12-01 is true

This is closer, but I also want '2004' to be true.

The next regex /\d{4}(?=-\d{2})/ produces the same results as the
previous regex:

 is false
2004 is false
200412 is false
20041201 is false
2004-12 is true
2004-12-01 is true

I've done quite a few regexes in the past but have never used the
positive lookahead assertion before because I have never really
understood it.

Out of the three regexes, I would have expected the first to fulfill my
requirements. I do not understand why it is not, although I suspect it
has something to do with the dash character.

What am I doing wrong here? I should be able to accomplish this test
using a single regex, right?

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

**
The information contained in this message, including attachments, may
contain 
privileged or confidential information that is intended to be delivered
only to the 
person identified above. If you are not the intended recipient, or the
person 
responsible for delivering this message to the intended recipient,
ALLTEL requests 
that you immediately notify the sender and asks that you do not read the
message or its 
attachments, and that you delete them without copying or sending them to
anyone else. 


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs




___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Regex Help

2005-01-27 Thread Dirk Bremer

I need to test for the following date-type strings:

2004
2004-12
2004-12-01

All of the above would be legal, any other combination would be illegal.

I have been using the following data to test the regex:

''Should produce a false result.
'2004'Should produce a true result.
'200412'  Should produce a false result.
'20041201'Should produce a false result. 
'2004-12' Should produce a true result.
'2004-12-01'  Should produce a true result.

My first attempt at a regex is /\d{4}(-\d{2})*/. This produces the
following result:

 is false
2004 is true
200412 is true
20041201 is true
2004-12 is true
2004-12-01 is true

I would prefer that '200412' and '20041201' would fail, i.e. be reported
as false. I'm not sure what's going on with this regex as I would expect
the following:

match the first four numeric characters, then match zero or more
occurrences of a dash character followed by two numeric characters

The next regex /\d{4}(-\d{2})+/ produces the following results:

 is false
2004 is false
200412 is false
20041201 is false
2004-12 is true
2004-12-01 is true

This is closer, but I also want '2004' to be true.

The next regex /\d{4}(?=-\d{2})/ produces the same results as the
previous regex:

 is false
2004 is false
200412 is false
20041201 is false
2004-12 is true
2004-12-01 is true

I've done quite a few regexes in the past but have never used the
positive lookahead assertion before because I have never really
understood it.

Out of the three regexes, I would have expected the first to fulfill my
requirements. I do not understand why it is not, although I suspect it
has something to do with the dash character.

What am I doing wrong here? I should be able to accomplish this test
using a single regex, right?

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Perl GUI Programming

2005-01-21 Thread Dirk Bremer
First of all, thanks for everyone's suggestions on Perl GUI extensions.
I have decided to use Tk. And thanks especially to Gerhard for his
pointers.

Here is the test program that I am working on:

#! C:/perl/bin/perl -w
use diagnostics;
use strict;
use warnings;

# Declare modules.
use FindBin qw($Bin);
use lib $Bin;

use Tk;

my $main = MainWindow->new(-title => 'Testing a Perl Tk Application');
$main->bind('' => sub {exit});
$main->minsize(600,300);
$main->geometry("600x300");

my $Frame1 = $main->Frame(-borderwidth=>'2',
  -relief=>'sunken',
 )->pack(
  -anchor => 'w',
  -fill => 'x',
  -ipady=>5,
  -ipadx=>5,
  -pady=>5,
  -padx=>10,
  -side=>'top');

my $Frame2 = $main->Frame(-borderwidth=>'2',
  -relief=>'sunken',
 )->pack(
  -anchor => 'w',
  -fill => 'x',
  -ipady=>5,
  -ipadx=>5,
  -pady=>5,
  -padx=>10,
  -side=>'top');

# Frame 1 widgets.
my ($Coop, $Cycle, $Date, $Job, $Type);  
my $Label1 = $Frame1->Label(-text => 'Job Type');
my $jobEntry   = $Frame1->Entry(-textvariable => \$Job,
-validate => 'focusout',
-validatecommand => sub {$_[1] =
uc($_[1]); $_[1] =~ /[BD]/},
-invalidcommand  => sub {print("Invalid
data value for $_[0]\n")},
-width => 1);
my $Label2 = $Frame1->Label(-text => 'Coop_ID');
my $coopEntry  = $Frame1->Entry(-justify => 'right',
-textvariable => \$Coop,
-width => 5);
my $Label3 = $Frame1->Label(-text => 'Cycle');
my $cycleEntry = $Frame1->Entry(-justify => 'right', 
-textvariable => \$Cycle,
-width => 2);
my $Label4 = $Frame1->Label(-text => 'Date');
my $dateEntry  = $Frame1->Entry(-width => 8,
-textvariable => \$Date);
my $Label5 = $Frame1->Label(-text => 'Type');
my $typeEntry  = $Frame1->Entry(-width => 1,
-textvariable => \$Type);
$Label1->pack(-side => 'left', -padx => 5);
$jobEntry->pack(-side => 'left', -padx => 5);
$Label2->pack(-side => 'left', -padx => 5,);
$coopEntry->pack(-side => 'left', -padx => 5);
$Label3->pack(-side => 'left', -padx => 5);
$cycleEntry->pack(-side => 'left', -padx => 5);
$Label4->pack(-side => 'left', -padx => 5);
$dateEntry->pack(-side => 'left', -padx =>5);
$Label5->pack(-side => 'left', -padx => 5);
$typeEntry->pack(-side => 'left', -padx => 5);

# Frame 2 widgets.
my $Search = $Frame2->Button(-text => 'Search', -command =>
sub{do_searchButton($jobEntry, $coopEntry, $cycleEntry, $dateEntry,
$typeEntry)});
my $Done   = $Frame2->Button(-text => "Done", -command => sub {exit});
$Search->pack(-side => 'left', -padx => 5, -pady => 5);
$Done->pack(-side => 'left', -padx => 5, -pady => 5);

$jobEntry->focus;
MainLoop();

I have a conceptual question as well as a practical question. The
conceptual question is what general methods do you use to validate the
user's entered data and force adherence to recognized/valid values?

The practical question can be taken from the example program. I am
attempting to use the various validation features for $jobEntry. My
concern is with the -invalidcommand. I tried the main->bell call without
success, i.e. not sound was heard, but while a bell-sound would be nice,
I am more concerned with not letting the user leave this entry until a
valid value has been entered. I have experimented with the various focus
properties without success. Basically what I would like to do here is
this:

1. Validate the entry with the -validatecommand. This appears to be
working.
2. If an invalid value is entered, have the cursor/focus remain in the
field in error.
3. Display a context-specific message in the GUI. I have considered
placing a label in the GUI for status messages. If the label refers to a
variable for its text, will the label be updated in the GUI if the
-invalidcommand sets the value of the variable? Would the program need
to do another pack on the status label to refresh its view of the lable
text variable?

TIA!

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc



___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Perl GUI Programming

2005-01-21 Thread Dirk Bremer
Let me pose a general Tk question as I'm having a bit of trouble
understanding the placement of widgets. I would like the following
layout:

label button
label button
label button
label button

I have tried various settings of -anchor and -side and the best that I
can come up with is:

label button label button label button label button

I have been using the pack geometry manager. Suggestions?

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Perl GUI Programming

2005-01-21 Thread Dirk Bremer
Gerhard,

Can you direct me to the location of the mailing list? 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 20, 2005 06:02
To: Dirk Bremer
Cc: perl-win32-users
Subject: Re: Perl GUI Programming

Hi Dirk,

I don't know, why Tk looks cumbersome to you - it's
well documented, you get a great book about it
("Mastering Perl/Tk" by Steve Lidie, Nancy Walsh at O'Reilly)
there's a living mailing list (Steve, Nick himself and a lot of
other great Tk specialists contribute a lot) and it's very easy to use.
It's also cross platform, of course. And you can re-use a lot of
knowledge should you ever need to develop a GUI for Tcl
(which God may save you from ;-)

Once you get over the initial hurdles (which you will face
with every GUI package), you won't find it cumbersome
anymore.

Regards,
Gerhard



|-+->
| | |
| | |
| | |
| | |
| |         |
| |"Dirk Bremer" <[EMAIL PROTECTED]>  |
| | |
| |Sent by: |
| |[EMAIL PROTECTED]|
| |.com |
| | |
| |2005-01-19 11:21 PM  |
| | |
|-+->
 
>---
|
  |
|
  |   To:   "perl-win32-users"

|
  |   cc:   (bcc: Gerhard Petrowitsch/STN/SC/PHILIPS)
|
  |   Subject:Perl GUI Programming
|
  |
|
  |   Classification:
|
  |
|
  |
|
 
>---
|




I am ready to attempt some GUI programming in Perl. I have looked at
Win32::GUI and need more documentation for it than I can readily find. I
have looked at Tk and it looks a bit cumbersome. What are you
recommendations? I require something that is compatible with 5.6 Perl. I
would like something that I can get up and running on quickly and that
is well documented for beginners. My primary interest will be in
developing a GUI that lists files for the user to choose and another GUI
that will be strictly as a scrolling display that will be updated often.
Your suggestions will be appreciated.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs




___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Perl GUI Programming

2005-01-20 Thread Dirk Bremer
wxPerl is interesting but very little documentation can be found. I will
require documentation from a complete beginner's viewpoint (for the GUI)
as I have literally no GUI programming experience although am
well-versed in Perl. 

-Original Message-
From: David Kaufman [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 19, 2005 18:43
To: Dirk Bremer; perl-win32-users
Subject: Re: Perl GUI Programming

Hi Dirk,

Dirk Bremer <[EMAIL PROTECTED]> wrote:
>
>I am ready to attempt some GUI programming in Perl. I have looked at
> Win32::GUI and need more documentation for it than I can readily
> find. I have looked at Tk and it looks a bit cumbersome. What are you
> recommendations? I require something that is compatible with 5.6
> Perl. I would like something that I can get up and running on quickly
> and that is well documented for beginners. My primary interest will
> be in developing a GUI that lists files for the user to choose and
> another GUI that will be strictly as a scrolling display that will be
> updated often. Your suggestions will be appreciated.


Check out wxPerl http://wxperl.sourceforge.net/

I use it to develop perl GUI apps on windows, and the PerlDevKit from 
www.activestate.com to compile them to windows.exe-cutables.

Here's a nice (if a bit old) tutorial:
http://www.perl.com/pub/a/2001/09/12/wxtutorial1.html

hth,

dave 


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Perl GUI Programming

2005-01-19 Thread Dirk Bremer
I am ready to attempt some GUI programming in Perl. I have looked at
Win32::GUI and need more documentation for it than I can readily find. I
have looked at Tk and it looks a bit cumbersome. What are you
recommendations? I require something that is compatible with 5.6 Perl. I
would like something that I can get up and running on quickly and that
is well documented for beginners. My primary interest will be in
developing a GUI that lists files for the user to choose and another GUI
that will be strictly as a scrolling display that will be updated often.
Your suggestions will be appreciated.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: File Buffering

2004-10-01 Thread Dirk Bremer \(NISC\)
Peter and Michael,

Your advice seems to have done the trick. Have a great weekend.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc
- Original Message - 
From: "Peter Guzis" <[EMAIL PROTECTED]>
To: "Dirk Bremer (NISC)" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Friday, October 01, 2004 15:44
Subject: RE: File Buffering


> select YOURFILEHANDLE;
> $| = 1;
>
> # enjoy unbuffered file goodness
>
> -Original Message-
> From: Dirk Bremer (NISC) [mailto:[EMAIL PROTECTED]
> Sent: Friday, October 01, 2004 1:28 PM
> To: [EMAIL PROTECTED]
> Subject: File Buffering
>
>
> I wrote and use a module that provides a standardized logging mechanism to
> STDOUT and to a defined log file. I have several Perl programs that run
all
> of the time and use this module. The log file is opened at the program
start
> and closed at the program end. There is nothing particularly fancy or
> complicated with the way that the module opens, writes, or closes the
file.
> The file is created as a normal text file and regular print functions are
> used to write to it.
>
> While a given program is running an writing to the log file, the log file
> can be opened in Notepad and the contents examined. Herein lies the issue,
> the program seems to lag behind in the writes to the log file based upon
the
> known program activity, i.e. there are entries I expect to see in the log
> file that are not there, but after a period of time, the log file will
catch
> up and I will see the results. All entries to the log file are timestamped
> so that I know when events occurred.
>
> I thing that there is some kind of file buffering going on here, i.e. the
> log entries are in a file buffer that has not been flushed to the file.
The
> file is using a specific file handle, i.e. it is not being written to
STDOUT
> or STDERR.
>
> I have never really understood the buffering mechanism as employed by Perl
> and could use some knowledge in this area. Specifically, how can I force
> every write to the log file to be unbuffered? Is the problem with
buffering
> or is there something else I should look at?
>
> Note: Using Perl 5.6.1 on Win2K.
>
> Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
> USA Central Time Zone
> 636-922-9158 ext. 8652 fax 636-447-4471
>
> [EMAIL PROTECTED]
> www.nisc.cc
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
>

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


File Buffering

2004-10-01 Thread Dirk Bremer \(NISC\)
I wrote and use a module that provides a standardized logging mechanism to
STDOUT and to a defined log file. I have several Perl programs that run all
of the time and use this module. The log file is opened at the program start
and closed at the program end. There is nothing particularly fancy or
complicated with the way that the module opens, writes, or closes the file.
The file is created as a normal text file and regular print functions are
used to write to it.

While a given program is running an writing to the log file, the log file
can be opened in Notepad and the contents examined. Herein lies the issue,
the program seems to lag behind in the writes to the log file based upon the
known program activity, i.e. there are entries I expect to see in the log
file that are not there, but after a period of time, the log file will catch
up and I will see the results. All entries to the log file are timestamped
so that I know when events occurred.

I thing that there is some kind of file buffering going on here, i.e. the
log entries are in a file buffer that has not been flushed to the file. The
file is using a specific file handle, i.e. it is not being written to STDOUT
or STDERR.

I have never really understood the buffering mechanism as employed by Perl
and could use some knowledge in this area. Specifically, how can I force
every write to the log file to be unbuffered? Is the problem with buffering
or is there something else I should look at?

Note: Using Perl 5.6.1 on Win2K.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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


Re: how to do a timeout of accept() in ActivePerl

2004-08-20 Thread Dirk Bremer \(NISC\)
- Original Message - 
From: "Bennett Haselton" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, August 20, 2004 14:52
Subject: how to do a timeout of accept() in ActivePerl


> However, I'm trying to do something similar in ActivePerl (v5.8.3 build
> 809) but the ActivePerl-Winfaq5.html file says that the alarm() function
is
> not implemented in ActivePerl.  So is there a way in ActivePerl to force a
> block of code to time out after a certain number of seconds?  This is the
> code that I'm trying to make time out:
>
> my $server = IO::Socket::INET->new( Proto => 'tcp',
>   LocalPort => $PORT,
>Listen=> SOMAXCONN,
>Reuse => 1);
> $server->accept();
>
> I tried seeing if the accept() function had its own timeout that I could
> use -- this is what the documentation says:
>
>  >>>
> accept([PKG])

Bennett,

I do soemthing similar by specifying the Timeout parameter like this:

my $Socket = IO::Socket::INET->new(LocalHost => $SocketServer,
   Listen=> 5,
   LocalPort => $Port,
   Proto => 'tcp',
   Reuse => 1,
   Timeout   => $Interval);

The value of the variable I am using, i.e. $Interval, can be set to whatever
you desire, it represents the number of seconds that the socket will listen
for a connection.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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


Re: How To Reload a Package/Module

2004-06-29 Thread Dirk Bremer \(NISC\)
This has been an interesting exercise of the Camel book. What I finally
found and what seems to satisfy my requirements is to do the following in
the master program:

our %the_shared_hash;
do 'the_module.pm';
import the_module;

I have tested this by altering the contents of the module while the program
was executing and it does express the changes to the module, which was my
desired result.

I will consider loading a file rather than the module for the future.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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


Re: :Oracle

2004-06-28 Thread Dirk Bremer \(NISC\)
- Original Message - 
From: "Richard Morse" <[EMAIL PROTECTED]>
To: "Ken Cornetet" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>; "Dirk Bremer (NISC)"
<[EMAIL PROTECTED]>
Sent: Monday, June 28, 2004 08:45
Subject: Re: :Oracle
>
> On my computers, if I use SQL Worksheet, I connect using username
> 'XXuser', password 'XXpass', and connection 'actris'.  The equivalent
> in Perl is:
>
> my $db = DBI->connect('dbi:Oracle:ACTRIS', 'XXuser', 'XXpass') or
> die(DBI->errstr);
>
> I find that if I don't capitalize the connection ('ACTRIS'), it doesn't
> work.  The case of the rest of the string matters as well (lowercase
> 'dbi', capital 'O').
>
> This should print all the available data sources (I enclosed the call
> in an eval because I get back errors with DBD::Proxy that halt the
> program).
>
> Note that the case of the returned drivers is important (eg, Oracle
> like 'dbi:Oracle', while ODBC likes 'DBI:ODBC'...)
>
> HTH,
> Ricky
>
>
>

Ricky,

This is the output of the simple script I am using to test the connection.

DBI::VERSION = 1.37
DBD::Oracle::VERSION = 1.06
ExampleP:
dbi:ExampleP:dir=.

ODBC:
DBI:ODBC:Test Mas Rdb 97
DBI:ODBC:AMS
DBI:ODBC:MQIS
DBI:ODBC:ECDCMusic
DBI:ODBC:OMS

Oracle:
dbi:Oracle:STARTEAM.xxx.xxx

Proxy:
Error while looking for sources for driver

mysql:
DBI:mysql:ftp_transfers
DBI:mysql:mysql
DBI:mysql:test

Use of uninitialized value in concatenation (.) or string at
C:/Perl/site/lib/DBI.pm line 584 (#1)
(W uninitialized) An undefined value was used as if it were already
defined.  It was interpreted as a "" or a 0, but maybe it was a mistake.
To suppress this warning assign a defined value to your variables.

To help you figure out what was undefined, perl tells you what operation
you used the undefined value in.  Note, however, that perl optimizes
your
program and the operation displayed in the warning may not necessarily
appear literally in your program.  For example, "that $foo" is
usually optimized into "that " . $foo, and the warning will refer to
the concatenation (.) operator, even though there is no . in your
program.

DBI connect('STARTEAM.xxx.xxx','rptcrm',...) failed:  at
C:\Perl\Scripts\PTest.pl line 28

The connect line is:

my $DBH = DBI->connect('dbi:Oracle:STARTEAM.xxx.xx','rptcrm','rptcrm');

Note that in all of the above examples, the notation 'xxx.xxx' relates to a
LAN address. When I connect using SQLPlus, I use a logon of "[EMAIL PROTECTED]" and
a password and it works. I have tried using the "[EMAIL PROTECTED]" in the Perl
script as the user, but it fails as well. I can connect using ODBC but would
prefer to use DBD::Oracle.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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


Re: :Oracle

2004-06-28 Thread Dirk Bremer \(NISC\)
- Original Message - 
From: "Richard Morse" <[EMAIL PROTECTED]>
To: "Ken Cornetet" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>; "Dirk Bremer (NISC)"
<[EMAIL PROTECTED]>
Sent: Monday, June 28, 2004 08:45
Subject: Re: :Oracle
>
> On my computers, if I use SQL Worksheet, I connect using username
> 'XXuser', password 'XXpass', and connection 'actris'.  The equivalent
> in Perl is:
>
> my $db = DBI->connect('dbi:Oracle:ACTRIS', 'XXuser', 'XXpass') or
> die(DBI->errstr);
>
> I find that if I don't capitalize the connection ('ACTRIS'), it doesn't
> work.  The case of the rest of the string matters as well (lowercase
> 'dbi', capital 'O').
>
> This should print all the available data sources (I enclosed the call
> in an eval because I get back errors with DBD::Proxy that halt the
> program).
>
> Note that the case of the returned drivers is important (eg, Oracle
> like 'dbi:Oracle', while ODBC likes 'DBI:ODBC'...)
>
> HTH,
> Ricky
>
>
>

Ricky,

This is the output of the simple script I am using to test the connection.

DBI::VERSION = 1.37
DBD::Oracle::VERSION = 1.06
ExampleP:
dbi:ExampleP:dir=.

ODBC:
DBI:ODBC:Test Mas Rdb 97
DBI:ODBC:AMS
DBI:ODBC:MQIS
DBI:ODBC:ECDCMusic
DBI:ODBC:OMS

Oracle:
dbi:Oracle:STARTEAM.xxx.xxx

Proxy:
Error while looking for sources for driver

mysql:
DBI:mysql:ftp_transfers
DBI:mysql:mysql
DBI:mysql:test

Use of uninitialized value in concatenation (.) or string at
C:/Perl/site/lib/DBI.pm line 584 (#1)
(W uninitialized) An undefined value was used as if it were already
defined.  It was interpreted as a "" or a 0, but maybe it was a mistake.
To suppress this warning assign a defined value to your variables.

To help you figure out what was undefined, perl tells you what operation
you used the undefined value in.  Note, however, that perl optimizes
your
program and the operation displayed in the warning may not necessarily
appear literally in your program.  For example, "that $foo" is
usually optimized into "that " . $foo, and the warning will refer to
the concatenation (.) operator, even though there is no . in your
program.

DBI connect('STARTEAM.xxx.xxx','rptcrm',...) failed:  at
C:\Perl\Scripts\PTest.pl line 28

The connect line is:

my $DBH = DBI->connect('dbi:Oracle:STARTEAM.xxx.xx','rptcrm','rptcrm');

Note that in all of the above examples, the notation 'xxx.xxx' relates to a
LAN address. When I connect using SQLPlus, I use a logon of "[EMAIL PROTECTED]" and
a password and it works. I have tried using the "[EMAIL PROTECTED]" in the Perl
script as the user, but it fails as well. I can connect using ODBC but would
prefer to use DBD::Oracle.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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


Re: Editor - finding lines

2004-05-27 Thread Dirk Bremer \(NISC\)


Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc
- Original Message - 
From: "Lee Goddard" <[EMAIL PROTECTED]>
To: "Capacio, Paula J" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>; "Perl-Win32-Users"
<[EMAIL PROTECTED]>
Sent: Thursday, May 27, 2004 09:12
Subject: Re: Editor - finding lines


>
> Capacio, Paula J wrote:
>
> >TextPad has a search across all open documents, or all files
> >in a directory.  The results are shown in a separate window and
> >double clicking the result takes you to that section of code in
> >that file.
> >Again like UltraEdit it's not free, but in the same price range.
> >It also has color syntax highlighting for perl and you can set up
> >the tools to execute perl from within the editor.
> >http://www.textpad.com
> >Paula
> >
> You can also supply a regex so that the output TP collects
> from a command (Perl, Java, C) is hyperlinked by filename/line number.
> So clicking "error at X.pm, line 10" takes you there.
>
> Another useful one is CTRL+M over a bracket (brace/angel-bracket, etc)
> to find the matching pair
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>


Multi-Edit does this nicely in a separate pane that lists the results of the
search. You then click on any of the results and the main pane will be
positioned to the affected line. This works both for a single file/window or
multiple files/windows. Multi-Edit is not a free product, somewhere around
$100.00. I have used it for years and have been very happy with it. I have
also heard good things about UltraEdit.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc


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


Re: DESTROY Issue

2004-05-27 Thread Dirk Bremer \(NISC\)
> Some light from Camel book 3rd edition,
> 12.6.1. Garbage Collection with DESTROY Methods:
> "When an interpreter shuts down, all its objects are destroyed,
> which is important for multithreaded or embedded Perl applications.
> Objects are always destroyed in a separate pass before ordinary
> references. This is to prevent DESTROY methods from using references
> that have themselves been destroyed."
>
> But something wrong in ActiveState Perl ;-((
> Are objects destroyed earlier than references and filehandles?
>
> I found two ways to avoid errors:
> 1. Rename DESTROY and manually call it like ordinary object method.
> 2. Objects must destroyed before "global destruction" (like above).
>
> -- 
> Best regards,
>  Lev


Lev,

I agree with your two assertions. It would appear that the answer to the
question is that filehandles are destroyed earlier than objects based upon
my testing. This is a very interesting subject that has repercussions for
filehandles in objects. I would love the opinion of an internals guru.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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


Re: DESTROY Issue

2004-05-25 Thread Dirk Bremer \(NISC\)

> What happens if you replace the:
>
> LogClose(shift);
>
> with
> $_[0]->LogClose();
>
> Cheers
>   Tobias
> >
> > Note the following code:
> >
> > sub DESTROY() {LogClose(shift); $Smtp->quit if (defined $Smtp)}
> >
> > I am getting an error when the DESTROY sub invokes the
> > LogClose sub. The error is as follows:
> >
> > (in cleanup) Uncaught exception from user code:
> > Can't use an undefined value as a symbol reference at
> > C:/Perl/Scripts/AmsLog.pm line 92 during global destruction.
> > AmsLog::LogClose('AmsLog=HASH(0x1ab51c8)') called at
> > C:/Perl/Scripts/AmsLog.pm line 42
> > AmsLog::DESTROY('AmsLog=HASH(0x1ab51c8)') called at
> > C:\Perl\Scripts\MovePDF.pl line 0 eval {...} called at
> > C:\Perl\Scripts\MovePDF.pl line 0
> >

I think there is a clue in the error messages. The DESTROY sub is not being
passed the object hash reference, it is being passed a string of
"AmsLog=HASH(0x1ab51c8)". If I do the following in the DESTROY sub:

sub DESTROY()
{
my $Self = shift;
print("$Self\n");
}

The same string, i.e. "AmsLog=HASH(0x1ab51c8)" is displayed. So now the
question becomes how do I get the object hash reference from this string or
how do I access the object hash from within the DESTROY?


Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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


Re: Passing command line options with ActivePerl

2004-05-25 Thread Dirk Bremer \(NISC\)
- Original Message - 
From: "Mike Trotman" <[EMAIL PROTECTED]>
To: "Frank D. Gunseor" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>; "TELARO BARTOLOMEO"
<[EMAIL PROTECTED]>
Sent: Tuesday, May 25, 2004 08:58
Subject: Re: Passing command line options with ActivePerl


> Do you have another program in your path called 'test'?
> (e.g. some shells have a built-in called 'test' - and its an obvious
> name (though a bad idea) to use on many projects).
> Can you run 'which test' - to see where your machine thinks 'test' is?
> Or can you run '.\test 1 2 3.?
>
> I only mention this as once - many years ago - I wasted a whole day on
> something exactly like this.
>
>

On my machine, a search of the ActiveState installation reveals multiple
instances of test.pl in multiple directories, so naming your own script
test.pl is not a good idea.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc


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


DESTROY Issue

2004-05-25 Thread Dirk Bremer \(NISC\)
Note the following code:

#! C:/perl/bin/perl -w
# AmsLog.pm 05/24/2004.

package AmsLog;

# Declare pragmas.
use diagnostics;
use strict;
use warnings;
use constant DEBUG => 0;

# Declare modules.
use FindBin qw($Bin);
use lib $Bin;
use Date::Format;
use Fcntl qw(:DEFAULT :flock);
use FileHandle;
use Net::SMTP;
use Win32::Message;

# Declare global variables.
my ($LogFile, $Smtp);

#--#
# Object constructor for this class.   #
#--#
sub new()
{
my $Proto = shift; # Class name argument.
my $Class = ref($Proto) || $Proto;
my $LogName = shift;   # File indentifier.
my $Self  = {Class => $Class, @_}; # Add the remaining arguments to the
class hash.
$ENV{DOMAIN} = 'nisc.cc';  # Specify the domain-name for SMTP.
$Smtp = Net::SMTP->new('xxx.xxx.xxx');
LogOpen($Self,$LogName);   # Define and open the log file.
return bless($Self,$Class);
}

#--#
# Object destructor for this class.#
#--#
sub DESTROY() {LogClose(shift); $Smtp->quit if (defined $Smtp)}

#--#
# Provide a method to define and open the log file.#
#--#
sub LogOpen()
{
my $Self= shift; # Class name.
my $LogName = shift; # File indentifier.
my $Str;

# Determine the pathname depending upon the machine name.
if ($ENV{COMPUTERNAME} =~ /(mail|sol)/i) {$LogFile = 'C:/Logs/'}
else {$LogFile = $ENV{TEMP}; $LogFile =~ s^\\^/^g; $LogFile .= '/'}

# Define the log filename.
$LogFile =
join('',$LogFile,time2str('%Y_%m_%d',time),'_',$LogName,'.log');

# If the log filename exists, open it for appending, else open it for
output.
if (-e $LogFile) {$Str = ">>$LogFile"}
else {$Str = ">$LogFile"}

# Create a filehandle reference that will be unique to each instance of
# this object and ad it to the object's hash.
$Self->{FH} = FileHandle->new();

# Open the log file.
die("Unable to open $LogFile $!, stopped") unless
(open($Self->{FH},$Str));
WriteLog($Self,"$Self->{Class}: $LogFile has been opened",0) if DEBUG;

# If requested, lock the log file.
if (exists($Self->{Lock}) and $Self->{Lock} == 1)
{
die("*** $LogFile cannot be locked ***") unless (flock($Self->{FH},
LOCK_EX | LOCK_NB));
WriteLog("$LogFile has been locked",0) if DEBUG;
}

WriteLog('SMTP object constructor call failed.',1) unless (defined
$Smtp);

return(1);
}

#--#
# Provide a method to close the log file.  #
#--#
sub LogClose()
{
my $Self = shift; # Class name.
my $FH   = $Self->{FH};
WriteLog($Self,"$Self->{Class}: Closing $LogFile",0) if DEBUG;
die("Close failed for filehandle $FH") unless (close($FH));
return(1);
}

I am getting an error when the DESTROY sub invokes the LogClose sub. The
error is as follows:

(in cleanup) Uncaught exception from user code:
Can't use an undefined value as a symbol reference at
C:/Perl/Scripts/AmsLog.pm line 92 during global destruction.
AmsLog::LogClose('AmsLog=HASH(0x1ab51c8)') called at
C:/Perl/Scripts/AmsLog.pm line 42
AmsLog::DESTROY('AmsLog=HASH(0x1ab51c8)') called at
C:\Perl\Scripts\MovePDF.pl line 0
eval {...} called at C:\Perl\Scripts\MovePDF.pl line 0

Line 92 is the actual close function call in the LogClose sub. I infer that
the $Self->{FH} is undefined at the point it is referenced in LogClose. This
is interesting as the 3rd edition of the Camel book, page 330, has a code
example very similar to what I am attempting to do. I realize it is probably
not neccessary to close the file and the most simple solution is not to
close the file. But on the other hand, I feel that something like this
should work. What am I doing wrong?

On a similar note, how could I display all of the key/value pairs in the
object hash?

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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


Re: Filehandle Question

2004-05-14 Thread Dirk Bremer \(NISC\)
> It occurs because the only kind of variable allowed for specifying the
> filehandle is a scalar--no array or hash elements. There are (or course)
> several solutions. One is actually documented in the entry for print in
> perlfunc:
>
> print({$Self->{FH}} "$TimeStamp$LogMsg\n");
>
> Another possibility is documented in FileHandle's documentation:
>
> $Self->{FH}->print("$TimeStamp$LogMsg\n");
>
> -- 
> Eric Amick
> Columbia, MD


I'd like to thank Eric for his first suggestion, which I arrived at shortly
after posting the question. One thing I find curious about the way the
filehandle has to be specified for the print function is that the special
notation using {} around the filehandle reference for the print function is
not required for the open and close functions. For example:

die("Unable to open $LogFile $!, stopped") unless
(open($Self->{FH},$Str));

die("Close failed for filehandle $Self->{FH}")
unless(close($Self->{FH}));

This may or may not be a moot point concerning the future evolution of Perl,
but I still find it curious that the filehandle references cannot be
specified in the same format for the print and open or close functions.



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


Re: Win32 - Browse for files.

2004-05-13 Thread Dirk Bremer \(NISC\)
>
> Hi,
>
> I have a need to create a small app for our support organization which
> primarily uses Windoze to do their day to day tasks.  Since they are
> not that command line savy I'd like to put together something that
> allows
> them to push a button or two to get their file(s) uploaded to various
> locations.
> Having used Perl/Tk in the past I know it's pretty straight forward
> using
> something like a ComboBox or other widget to get the visual stuff done.
>
> This time I'd like to try to put something together that appears a
> little
> more native and not having a lot of Win32::GUI, Win32::API experience I
> need some help getting started.  Can someone help me with a explorer
> type
> control that would allow a user to navigate to a file?  I can probably
> take it from there.
>
> Many Thanks!
>
> Carter.

Carter,

I had the same requirement and used the following code:

use Win32::FileOp;

# Solicit the user via a dialog box to select the files to be processed.
@Files = Win32::FileOp::OpenDialog(-title   => "Select File(s) to process",
   -filters => ['All Files' => '*.*'],
   -defaultfilter => 1,
   -dir => 'c:\\',
       -filename => '*.*',
   -options => OFN_ALLOWMULTISELECT |
OFN_EXPLORER);

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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


Re: MySQL/Perl

2004-04-09 Thread Dirk Bremer \(NISC\)
- Original Message - 
From: "Joe Youngquist" <[EMAIL PROTECTED]>
To: "Dirk Bremer (NISC)" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Friday, April 09, 2004 13:29
Subject: Re: MySQL/Perl


> from the DBI docs:
>
> the connect string is:
> $dbh = DBI->connect($data_source, $username, $auth, \%attr);
>
> where data_source = "DBI:mysql:NameOfDatabase:HostNameOrIP",
> where username = "allowable username" (try root first, root should always
> have permissions to databases, so the removes a possible user permission
> issue),
> where auth = "users_password" (default mysql install on Window's the
"root"
> user password is blank ... very secure!)
>
> Assuming your database is on the computer your running the test scripts
from
> try:
> 
> use DBI;
> my $dbh = DBI->connect('DBI:mysql:mysql:dbremer', 'root', '')
>  or die "\nI could not connect to the
> database\n$DBI::errstr";
> $dbh->disconnect;
> exit(0);
> --
> if your Perl.exe is still crashing, try removing DBI and DBD::Mysql and
> reinstalling them.

Removing DBI and DBD::mysql and then reinstalling them proved to be the
trick. Thanks to everyone for assisting me with all of my questions and I
wish everyone a great weekend with decent weather to boot!

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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


Re: Win32::GUI Question

2004-03-12 Thread Dirk Bremer \(NISC\)
I am not interested in File::Find for this particular task, although I am
familiar with its capabilities.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc
- Original Message - 
From: "Grant Babb" <[EMAIL PROTECTED]>
To: "Dirk Bremer (NISC)" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Friday, March 12, 2004 09:31
Subject: RE: Win32::GUI Question


File::Find performs that task quickly and efficiently.  You can copy the
example from the POD and you are ready to go.


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Dirk Bremer (NISC)
Sent: Friday, March 12, 2004 8:55 AM
To: [EMAIL PROTECTED]
Subject: Win32::GUI Question

Someone recently posted a code example using Win32::GUI to browse for a
folder, ala:

$Dir  = GUI::BrowseForFolder(-title => "Win32::GUI::BrowseForFolder
test");

Is there a similar method to browse a folder for the files contained
within and to allow the selection of multiple files, returning the
selected filename(s)?

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters USA
Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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




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


Win32::GUI Question

2004-03-12 Thread Dirk Bremer \(NISC\)
Someone recently posted a code example using Win32::GUI to browse for a
folder, ala:

$Dir  = GUI::BrowseForFolder(-title => "Win32::GUI::BrowseForFolder test");

Is there a similar method to browse a folder for the files contained within
and to allow the selection of multiple files, returning the selected
filename(s)?

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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


Win32::Process

2004-02-27 Thread Dirk Bremer \(NISC\)
I have used Win32::Process in several scripts. what I can't figure out about
using it is how to create a minimized window. Looking at the constants used
with Win32:Process, I don't have a clue as to what some of them mean:

CREATE_DEFAULT_ERROR_MODE
CREATE_NEW_CONSOLE
CREATE_NEW_PROCESS_GROUP
CREATE_NO_WINDOW
CREATE_SEPARATE_WOW_VDM
CREATE_SUSPENDED
CREATE_UNICODE_ENVIRONMENT
DEBUG_ONLY_THIS_PROCESS
DEBUG_PROCESS
DETACHED_PROCESS
HIGH_PRIORITY_CLASS
IDLE_PRIORITY_CLASS
INFINITE
NORMAL_PRIORITY_CLASS
REALTIME_PRIORITY_CLASS
THREAD_PRIORITY_ABOVE_NORMAL
THREAD_PRIORITY_BELOW_NORMAL
THREAD_PRIORITY_ERROR_RETURN
THREAD_PRIORITY_HIGHEST
THREAD_PRIORITY_IDLE
THREAD_PRIORITY_LOWEST
THREAD_PRIORITY_NORMAL
THREAD_PRIORITY_TIME_CRITICAL

I've been using the CREATE_NEW_CONSOLE which will open a new console window.
I have tried CREATE_NO_WINDOW which indeed creates a process without an
associated window. There is no choice that is obvious to create a minimized
window. Is this possible with Win32:Process or should a console window as
created by Win32:Process use some other method to minimize the window once
it has been created?

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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


Re: 'which' functionality in Perl

2003-09-30 Thread Dirk Bremer \(NISC\)
d the PATH and PATHEXT environment variables. Example:
>
>   C:\Temp>which -# which*
>   Debugging C:\Temp\which.pl -d which
>  version  = v1.4 2003/09/14
>  debug= 1
>  filename = which
>  PATHEXT  = .COM .EXE .BAT .CMD .VBS .VBE .JS .JSE .WSF .WSH .PL
>   Matches:
>  .\which.pl
>  C:\Pkgs\bin\which.pl
>  C:\Pkgs\bin\which0.bat
>   which.pl: Finished
>
>
> This may be overkill for your needs, but I have found
> this to be an extremely useful utility on my Win32
> platform. I add to it occasionally when I find more
> things that I want it to be able to do.
>
> You can get it here:
>
>   http://marms.sourceforge.net/perl/
>
> --
> Mike Arms


Mike,

I changed a 2 lines in your which.pl that seems to have cured the problem
with the directories with spaces in their names. Through some
experimentation, glob seems to like the forward slashes better than the
backword slashes. Also placing quotation marks around the entire string to
be globbed helped with the embedded spaces in the pathnames. Please consider
incorporating these changes into your current version.

If anyone can think of a better way to quote the argument to glob, please
let me know.

if ( $win32 )
{
$dir =~ s!\\!/!g;
my @glob = glob(join('','"',$dir,'/',$searchname,'.*"'));
for my $f (@glob)
{
   for my $ext (@pathext)
   {
   next unless $f =~ /$ext$/i && -f $f;
   print $pad . file_info( $f ) . "$f\n";
   $found++;
   }
}
 }

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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


Re: newbie hlelp!

2003-09-16 Thread Dirk Bremer \(NISC\)
- Original Message - 
From: "alex p" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, September 16, 2003 11:42
Subject: Re: newbie hlelp!


> Thank you all for replying, I am using the code below and I am still
unable
> to get the correct date
> 
> opendir (DIR, "$server\\c\$\\sys\\data\\LOG\\updates");
>   @allfiles = readdir(DIR);
>   #print("," readdir(DIR));
>   #closedir(DIR);
>   foreach $f (@allfiles)
>   {
>   unless ( ($f eq ".") || ($f eq "..") )
> {
>   print "$f\n";
>   (undef,undef,undef,$dom,$mon,$year)=localtime((stat($f))[9]);
>   $mon++;
>   $year += 1900;
>   $dateval = printf("%04d%02d%02d\n",$year,$mon,$dom);
>}
> 
> the output of printf is: 19691231  for every file?
> what am I doing wrong?
> the date should be yesterdays date 20030915
>

Alex,

I found that the method that worked best for me in a similar circumstance
was to parse the output of the DOS dir command.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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


Re: pound sign trouble

2003-07-08 Thread Dirk Bremer \(NISC\)
- Original Message - 
From: "$Bill Luebkert" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 08, 2003 05:05
Subject: Re: pound sign trouble


> [EMAIL PROTECTED] wrote:
> >
> >>If you redirect that output
> >>to a file and then look at the file with an editor (Vim in my case),
> >
> >
> > This depends on the editor, DOS-based editors may interpret 156
> > as the pound sign whereas Windows-based ones (e.g. Notepad) will
> > display 163 as the pound sign.
>
> Windoze doesn't have a real editor - you have to get a real editor
> from somewhere else.  :)

In addition to the thoughts on codepage difference, this could also be a
font issue. The command prompt uses a different font set than say, for
example, Notepad. The monetary pound character is more than likely mapped to
different locations within the fonts. I looked at both a Courier and Times
New Roman fonts, and both have the monetary pound character mapped to
location 163. A console window normally uses raster fonts, which I cannot
locate to examine. You can try changing the console font to Lucinda Console,
which does have the monetary pound character mapped to location 163.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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


Re: Parsing test file question

2003-03-07 Thread Dirk Bremer \(NISC\)
- Original Message -
From: "James" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 06, 2003 22:14
Subject: Parsing test file question


> Hi all,
>
> I have a test file which conatin words separated by
> comma and I would like to process and print the result
> to an ouput file. The output file should only have at
> most 32 characters per line.If the line read is more
> than 32 char, then the rest should be printed in the
> next line. Can anybody help me with this?
>
> This is the input file:
>
> ###   INPUT  FILE 
> AA1234,AA3134,AA1345,AA091,A2,AA1206,AAA0912,AA8731
> BB1344
> C1,CC1299,CC2425,0965,C4,CC1400,CCC1345,CC0012,CC231
> DD6623,DD1200,DDD2456,DDD1123,D2,DD1206,D1,DD0011,D3
> EE5609,EE1200
>   END  ##
>
> And I want to create an ouput file like this(print the
> word read but cannot have more than 32, if more print
> it in the next line):
>
>  OUTPUT FILE #
> AA1234,AA3134,AA1345,AA091,A2,
> AA1206,AAA0912,AA8731
> BB1344
> C1,CC1299,CC2425,0965,C4,
> CC1400,CCC1345,CC0012,CC231
> DD6623,DD1200,DDD2456,DDD1123,
> D2,DD1206,D1,DD0011,D3
> EE5609,EE1200
>   END  
>

James,

Assuming that you have opened the files, have a loop that reads the input
file line by line and assigns the current line to $_ after chomping it, and
that the output file filehandle is FHO:

if (length($_) > 32) {print(FHO substr($_,0,32),"\n"); print(FHO
substr($_,31),"\n")}
else {print(FHO "$_\n"}


Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc


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


Re: Trouble with my variables.

2003-02-18 Thread Dirk Bremer \(NISC\)
- Original Message - 
From: "Beckett Richard-qswi266" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 18, 2003 10:07
Subject: RE: Trouble with my variables.


> Still having harassments...
> 
> I now invoke the sub thusly...
> 
> update_value("ftp", $ftp{$key}{value}, $key);
> 
> The sub is like this...
> 
> sub update_value {
> $entry{$_[0]}{$key} -> delete (0, "end");
> $entry{$_[0]}{$key} -> insert ("end", $_[1]);
> }
> 
> I get:
> 
> Global symbol "$key" requires explicit package name at v06b.pl line 1561.
> Global symbol "$key" requires explicit package name at v06b.pl line 1562.
> Execution of v06b.pl aborted due to compilation errors.
> 
> If I use $_[2] instead of $key, then it works. Is there a way of passing
> $key as $key to the sub?
> 
> Thanks.
> 
> R.



sub update_value {
my $key = $_[2];
...

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

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



Re: File Formatting in Perl

2003-01-29 Thread Dirk Bremer \(NISC\)
- Original Message -
From: "Kenneth Jideofor [ MTN - Ikoyi ]" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 29, 2003 13:50
Subject: File Formatting in Perl


> Hi all,
>
> I have file whose content is arranged in rows of two lines, each row-pair
> separated from the next by a line-space.
> I want to rearrange the file in a two-column format such that all the
> entries in the first rows in a pair are put in the first column while
their
> corresponding second rows are put in the second column.
>
> For instance,
>
> Given the content of a file as:
>
> 
> 
>
> 
> 
>
> 
> 
>
> I want it rearranged in the following format using Perl:
>
>  
>  
>  
>
> I look forward to your assistance.

my $line = undef;

open(FH,"<$ARGV[0]") or die("Cannot open input file");
while()
{
chomp;
next unless(length > 0);
unless(defined $line){$line = $_}
else {print("$line $_\n"); $line = undef}
}
close(FH) or die 'Close failed for filehandle FH';

*** Untested ***

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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



Re: socket application

2003-01-28 Thread Dirk Bremer \(NISC\)
- Original Message -
From: "Jeff Slutzky" <[EMAIL PROTECTED]>
To: "'Dirk Bremer (NISC)'" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Tuesday, January 28, 2003 15:42
Subject: RE: socket application


> I'm glad my question was inspiring.  I am trying to get this to work on my
> Win2000 Workstation and it just hanging, not erroring out or anything.  I
> tested your code on another SCO server and it works like a charm.  What
> platform did you test this on?  I thank you again for your help.
>


Jeff,

I tested both the sender and receiver scripts on Win2k boxes. No Unix
available to play with.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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



Re: socket application

2003-01-28 Thread Dirk Bremer \(NISC\)
- Original Message -
From: "Gerber, Christopher J" <[EMAIL PROTECTED]>
To: "'Dirk Bremer (NISC)'" <[EMAIL PROTECTED]>
Sent: Tuesday, January 28, 2003 15:25
Subject: RE: socket application


> Dirk,
>
> I had hacked together something like this in C at one point.  I think I
have
> a copy of the source code at home.  I'll see if I can find it and then we
> can talk about turning it into Perl.  If I can't find it, I should at
least
> be able to find the API calls.  Are the processes that you're killing
> regular apps, or services.  (Services would be easier.)
>
> Chris
>

Chris,

They are not services and written in the WinBatch scripting language that
supports the creation of its own windows. They are not console windows per
se, but similar. I have used something in Win32::GUI to locate a particular
window by its title, but have no idea how to kill the window once it has
been located.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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



Re: socket application

2003-01-28 Thread Dirk Bremer \(NISC\)
- Original Message -
From: "Jeff Slutzky" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 28, 2003 13:13
Subject: socket application


> I am attempting to make a socket server running on a Win98 platform and
> have a socket client connecting from a SCO Unix platform.  What happens is
> that I start the server and it sits waiting, I then connect from the SCO
> server with the client socket app and I detect a connection on the Windows
> box.  What doesn't happen is the client sends a "Hello" string to the
> server and the server does not read what's going through the socket.
>
> sockets.pl - running on a Win98 box.
>
> use IO::Socket;
>
> my $sock = new IO::Socket::INET (LocalHost => '192.168.2.39', LocalPort =>
> '7801', Proto => 'tcp', Listen => 1, Reuse => 1,);
> die "Could not create socket: $!\n" unless $sock;
> my $new_sock = $sock->accept();
> print "accept\n";
> while($new_sock) {
> print $_;
> }
> close($sock);


Jeff,

I played around with your code a bit, never having used sockets before, and
came up with this functioning version of your program.

my $Socket;
my $RDR = new IO::Socket::INET (LocalHost => 'XXX.XXX.XXX.XXX', LocalPort
=>'7801', Proto => 'tcp', Listen => 1, Reuse => 1);
die("Could not create socket: $!") unless($RDR);
while($Socket = $RDR->accept())
{
while (<$Socket>) {chomp; print(">$_<\n")}
}

close($RDR);
close($Socket);

To all,

Jeff's initial code inspired me to play around a bit with an idea I've had
for a while. I would like to able kill and then restart certain processes on
another machine. Using code similar to above, I have tested it on the other
machine and it does receive messages sent from my machine. Both machines are
Win2K. I would send predefined commands to the other machine to kill a
specific process, then update the programs on the other machines by an
external and manual process, and then would send other predefined commands
to restart the programs. I think I can handle sending and receiving the
messages and the restarting of the programs. The one piece of information I
will need is how to kill the processes on the other machine. This can be
done from the receiving socket program that will be executing on the other
machine. Both of the processes I am interested in killing run in separate
windows with specific window titles. Which is the best way to locate these
processes and then kill them? Note that neither of the processes on the
remote machine are written in Perl. Your suggestions will be appreciated.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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



Re: Get IP Address

2003-01-22 Thread Dirk Bremer \(NISC\)
Capture the output of the Win9x ipconfig command, i.e.:

my @results = `ipconfig`;

You will have to parse the results slightly. This command also lists other
information that may be of interest.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc
- Original Message -
From: "Jeff Slutzky" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 22, 2003 13:32
Subject: Get IP Address


> Is there a quick and dirty way to get the IP address for a Win9x PC?
>
> --
--
> Jeffrey L. Slutzky
> Manager System Administration
> 402.501.4860 (Direct)
> 402.850.4860 (Cell)
> Affinitas - Latin for "Relationship"
> Helping Businesses Acquire, Retain, and Cultivate Customers
> Visit us at http://www.affinitas.net
> --
> 1015 N. 98th Suite 100
> Omaha, NE 68114
> --
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
>

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



Re: Globbing speed

2003-01-22 Thread Dirk Bremer \(NISC\)
- Original Message -
From: "Tillman, James" <[EMAIL PROTECTED]>
To: "'Conrad, Ben'" <[EMAIL PROTECTED]>; "Perl-Win32-Users"
<[EMAIL PROTECTED]>
Sent: Wednesday, January 22, 2003 11:58
Subject: RE: Globbing speed


> Sure:
>
> *  Don't use fileglobs, and open a dirhandle instead.  You'll get results
as
> soon as you process the first file.
> *  Use cygwin and run ActiveState perl while in bash.  cmd.exe is retarded
> in many respects, one of which is file-globbing.  Perl is having to make
up
> for its limitations by itself, which causes the delay.
>
> Hope this helps.
>
> jpt
>
> > -Original Message-
> > From: Conrad, Ben [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, January 22, 2003 11:59 AM
> > To: Perl-Win32-Users
> > Subject: Globbing speed
> >
> >
> > Folks,
> >
> > I'm do a lot of opening up of directories and operating on
> > all files in that directory.  Is there a faster way to
> > populate handles than:
> >
> > while ($filename = <$source/*>) {
> > ...
> > }
> >
> > On large directories this takes several minutes before -any-
> > of the code in the while() loop is executed.  In the most
> > recent example my directory has 14,000+ files.  "dir" from
> > cmd.exe is really fast and so is Windows Explorer, they both
> > give me all the attributes of the files too!
> >
> > Is there a better, faster, Perlish way to glob a directory?

Ben,

If you are strictly operating on Win32, the dir command is faster than any
pure Perl solution:

my $src  = 'c:\perl\scripts\\';
my @list = `dir /b/s \"$src\"`;

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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



MS Excel

2002-12-17 Thread Dirk Bremer \(NISC\)



I would like to write a script to:
 
1. Start Excel
2. Open a new worksheet
3. Populate cells
4. Apply simple attributes to selected rows (i.e. bold font, 
etc.)
 
While I have experience both with Perl and Excel, I have never 
accessed Excel from Perl. Any pointers and tips on how to 
get started will be appreciated. 
Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. 
Peters636-922-9158 ext. 8652 fax 636-447-4471
 
[EMAIL PROTECTED]www.nisc.cc


Re: Hangs on 2nd iteration of loop

2002-12-12 Thread Dirk Bremer \(NISC\)



Ullrich,
 
I suspect that your problem is that you are reading a large 
file into an array, i.e. 
 
(@inrecs = )
 
I think your will find that the program will work better if you eliminate 
the array and instead read the input and write the output line by line rather 
than all at once.  
Dirk Bremer - Systems 
Programmer II - ESS/AMS  - NISC St. Peters636-922-9158 ext. 8652 fax 
636-447-4471
 
[EMAIL PROTECTED]www.nisc.cc

  - Original Message - 
  From: 
  Ullrich 
  Fischer 
  To: [EMAIL PROTECTED] 
  
  Sent: Thursday, December 12, 2002 
  13:05
  Subject: Hangs on 2nd iteration of 
  loop
  The following almost 
  trivial program hangs the 2nd time it gets to the 
  else 
  { that is shown in large bold font below.   CPU utilization 
  is pegged at 100% and Task Manager shows 99% of CPU time going to 
  perl.exe.  This condition lasts until I hit Ctrl-C on the DOS window 
  containing the perl program session.The first input file is about 5 
  MB, the 2nd is about 6 Mb.  When I rename the first input file to 
  something else, it hangs on what was the third file but is now the 2nd, so it 
  doesn't seem to be related to the contents of the input file.debug 
  shows that the close commands at the end of the innermost foreach loop 
  succeed.   The first output file is created and seems to contain the 
  expected results.  The 2nd output file is not created.I've pasted 
  details of my configuration and Perl versions below the program 
  code.# datefx.pl # changes mm/dd/ format dates to 
  mmdd  formatmy $rtdir;my @infils;my 
  @inrecs;$rtdir = "C:\\doc\\stocks\\openord\\";chdir($rtdir) || die 
  "Unable to go to $rtdir";@infils = glob "*.csv";foreach $infil 
  (@infils) {  $opened = open INFIL, $infil;  unless ($opened) 
  {print "Unable to open $infil for read\n";  }  else 
  {   print "$infil opened 
  \n";   
  @inrecs=("");   unless (@inrecs = 
  ) {print "Unable to read from $infil \n"; }       else 
  {    
  $outfil = 
  $infil."out";    
  $openout = open OUTFIL, 
  ">$outfil";    
  unless ($openout) { print "Unable to open $outfil to write 
  \n";    
  }    else 
  { 
  print "Opened 
  $outfil\n"; 
  foreach $inrec (@inrecs) 
  {   
  $indte = substr $inrec, 0, 
  10;   
  @indte = split /\//, 
  $indte;   
  substr($inrec, 0, 10) = 
  $indte[2].$indte[0].$indte[1];   
  print OUTFIL 
  $inrec; 
  } 
  $closed = close OUTFIL; print "close $outfil returns $closed 
  \n"; 
  $closed = close INFIL; print "close $infil returns $closed 
  \n";    
  }   }  
}}


Re: perl-win32-users - Best way to return a path to a file ?

2002-12-04 Thread Dirk Bremer \(NISC\)



Neil,
 
This is a little sub that I rolled up to provide the path, 
filename, and extension:
 
sub Fparse($){    local $_ = 
shift;    my ($Delim, $Fp, $Fn, $Fe, $Pos1, 
$Pos2);
 
    # Check whether the filename contains 
forward or backward slashes.    $Delim = (index($_,'/') > 
-1) ? '/' : '\\';
 
    # Find the last slash in the 
filename.    $Pos1 = rindex($_,$Delim);
 
    # Extract the path if 
present.    if ($Pos1) {$Pos1++; $Fp = substr($_,0,$Pos1)} 
else {$Fp = undef; $Pos1 = 0}
 
    # Find the last period in the 
filename.    $Pos2 = rindex($_,'.');
 
    # Extract the name and 
extension.    if ($Pos2) {$Fn = substr($_,$Pos1,$Pos2 - 
$Pos1); $Pos2++; $Fe = substr($_,$Pos2)}    else {$Fn = 
substr($_,$Pos1); $Fe = undef}
 
    
return(($Fp,$Fn,$Fe));}
=item Fparse($filename)
 
=item
 
=over 4
 
This routine accepts a string as an argument that will contain 
afilename and will parse the filename into the path, name, and 
fileextension. The parsed elements will be returned as an lvalue. An 
undefwill be returned for elements that do not exist in the passed filename, 
i.e.path and/or file extension.
You could select just the path like this, assuming $file 
contains the fully qualified filename:
 
($path, undef, undef) = Fparse($file);
Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. 
Peters636-922-9158 ext. 8652 fax 636-447-4471
 
[EMAIL PROTECTED]www.nisc.cc

  - Original Message - 
  From: 
  Neil 
  
  To: [EMAIL PROTECTED] 
  
  Sent: Wednesday, December 04, 2002 
  10:48
  Subject: perl-win32-users - Best way to 
  return a path to a file ?
  
  Hi,
   
  I have just started to code up a subroutine to 
  return the path only from a complete path to a file. This must the the 3rd 
  time in two months as I have mislaid the routine on my HD and searching for it 
  would probably take longer than the coding.
   
  When writing this routine, I always seem to take 
  the long way round and this got my curiosity going and wondering what 
  other solutions people have come up with that are more elegant and obvious 
  than my own.
   
  I find many times that looking at someone elses 
  code can provide an "aha" moment that last far beyong the snippet 
  involved.
   
  If anyone cares to share their code for this - 
  that would be cool. If not - thats cool too. I am gonna head back to the 
  editor and throw it together - again ;-) and I'll post it later so we can 
  flame it in a public display of humiliation ;-)
   
  Neil


Re: PPM "set save" not saving repositories

2002-11-21 Thread Dirk Bremer \(NISC\)
Joe,

There have been some threads on this subject in the past concerning the
corruption of the perl\site\lib\ppm.xml file that stores all of the
information for ppm. You might be able to reconstruct this file by editing
it or other means, otherwise, reinstall your Perl installation and ppm will
function again, but it will lose all information about any modules that you
have installed that are not part of the standard installation.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc
- Original Message -
From: "Joseph P. Discenza" <[EMAIL PROTECTED]>
To: "Perl-Win32-Users Mailing List"
<[EMAIL PROTECTED]>
Sent: Thursday, November 21, 2002 15:16
Subject: PPM "set save" not saving repositories


All,

Build 626, PPM version 2.1.5. I "set repository BLAH...", then
"set save", and then quit and restart PPM. Voila, my repositories
are gone (in fact, I don't have *any* repositories).

Other parameters do seems to be saved: confirm, for example.

Any ideas?

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


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



Re: Newbie Question

2002-11-21 Thread Dirk Bremer \(NISC\)
- Original Message -
From: "Laura Meli" <[EMAIL PROTECTED]>
To: "Perl-Win32-Users" <[EMAIL PROTECTED]>
Sent: Monday, November 11, 2002 07:41
Subject: Newbie Question


> Hi everyone,
>
> I am just starting out to use perl to write my test scripts.  I was
> wondering if there was a way to call one perl program from another.  I
know
> that if I have a .pm module then I call it by the use function.  How about
a
> .pl file?  I want be able to choose which tests I run each time I execute
my
> perl script.  My plan was to create a separate perl script for each test
> suite then have one main perl script which calls the scripts I want to
> execute.
>
> Thanks in advance for your help.  The emails I receive from this group
have
> been really helpful.


Laura,

There are many ways dpending upon your requirements. You might check out the
following:

do
eval
system

system in particular might be your best choice. There are certain times when
I want to execute scripts in a separate command window from the calling
script, like this snippet:

use Win32::Process;
$Params = join('','perl -w Doc1BillSelect.pl ',$Dir,$ARGV[0],'.dat
',$TempSvd,' ',$ARGV[1],' 4 \"',join(' ',@Args),'\"');

# Execute the selection program.
Win32::Process::Create($Process,'C:/Perl/Bin/perl.exe',$Params,0,CREATE_NEW_
CONSOLE,'c:/perl/scripts') || die ErrorReport();
$Process->Wait(INFINITE);

sub ErrorReport() {print(Win32::FormatMessage(Win32::GetLastError()));
return(1)}

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc


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



Re: when localtime isn't?

2002-10-23 Thread Dirk Bremer \(NISC\)
Oops, I think I have it backwards:

CDT = GMT - 5. MDT = GMT - 6. CST = GMT - 6. MST = GMT - 7.

So, today you should be 6 hours earlier than GMT. I wonder if it is a
problem with the way you have your TZ set.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc
- Original Message -
From: "Dirk Bremer (NISC)" <[EMAIL PROTECTED]>
To: "perl-win32-users" <[EMAIL PROTECTED]>
Sent: Wednesday, October 23, 2002 10:57
Subject: Re: when localtime isn't?


> I ran your code here in CDT:
>
> 58 52 10 23 9 102 3 295 1
> Local: Wed Oct 23 10:52:58 2002
>   GMT: Wed Oct 23 15:52:58 2002
>
> CDT = GMT - 6. MDT = GMT - 7. CST = GMT - 5. MST = GMT - 6. It looks to me
> that the culprit is gmtime, it is not taking into account the daylight
> savings time offset.
>
> Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
> 636-922-9158 ext. 8652 fax 636-447-4471
>
> [EMAIL PROTECTED]
> www.nisc.cc
> - Original Message -
> From: <[EMAIL PROTECTED]>
> To: "perl-win32-users" <[EMAIL PROTECTED]>
> Sent: Wednesday, October 23, 2002 10:24
> Subject: when localtime isn't?
>
>
> >
> >
> >
> >
> >
> > Ok, localtime() has always done what I expected in the past, but on my
> > win2k machine(and 3 others I have tested), it doesn't.
> >
> > Under win2k this
> >
> > print "TZ = $ENV{TZ}\n";
> > @time = localtime();
> > print "@time\n";
> > print "Local: " . scalar localtime() . "\n";
> > print "  GMT: " . scalar gmtime() . "\n";
> >
> > says this:
> >
> > TZ = MST-7MDT
> > 48 46 22 23 9 102 3 295 1
> > Local: Wed Oct 23 22:46:48 2002
> >   GMT: Wed Oct 23 14:46:48 2002
> >
> >
> > So, the GMT is correct -- it's 8:46am MST == GMT - 7 hours + 1 for DST,
> but
> > localtime is returning GMT + 8 hours.  My NT machine set to the same
> > timezone correctly reports the same GMT and the correct localtime.  So,
> the
> > question is, what do I have configured wrong? (surely localtime is not
> > broken!)
> >
> > Steve
> >
> >
> > ___
> > Perl-Win32-Users mailing list
> > [EMAIL PROTECTED]
> > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> >
> >
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
>

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



Re: when localtime isn't?

2002-10-23 Thread Dirk Bremer \(NISC\)
I ran your code here in CDT:

58 52 10 23 9 102 3 295 1
Local: Wed Oct 23 10:52:58 2002
  GMT: Wed Oct 23 15:52:58 2002

CDT = GMT - 6. MDT = GMT - 7. CST = GMT - 5. MST = GMT - 6. It looks to me
that the culprit is gmtime, it is not taking into account the daylight
savings time offset.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc
- Original Message -
From: <[EMAIL PROTECTED]>
To: "perl-win32-users" <[EMAIL PROTECTED]>
Sent: Wednesday, October 23, 2002 10:24
Subject: when localtime isn't?


>
>
>
>
>
> Ok, localtime() has always done what I expected in the past, but on my
> win2k machine(and 3 others I have tested), it doesn't.
>
> Under win2k this
>
> print "TZ = $ENV{TZ}\n";
> @time = localtime();
> print "@time\n";
> print "Local: " . scalar localtime() . "\n";
> print "  GMT: " . scalar gmtime() . "\n";
>
> says this:
>
> TZ = MST-7MDT
> 48 46 22 23 9 102 3 295 1
> Local: Wed Oct 23 22:46:48 2002
>   GMT: Wed Oct 23 14:46:48 2002
>
>
> So, the GMT is correct -- it's 8:46am MST == GMT - 7 hours + 1 for DST,
but
> localtime is returning GMT + 8 hours.  My NT machine set to the same
> timezone correctly reports the same GMT and the correct localtime.  So,
the
> question is, what do I have configured wrong? (surely localtime is not
> broken!)
>
> Steve
>
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
>

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



Re: use require question

2002-10-02 Thread Dirk Bremer \(NISC\)

Jasper,

You could try a low overhead version:

script_1.pl
use strict;
our $var1 = 'foo';
our $var2 = 'bar';
1;

script_2.pl
use strict;
require "script_1.pl";
print "In script_2.pl: $script_1::var1, $script_1::var2\n";

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

- Original Message -
From: "Buch, Jasper (Jasper)" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 02, 2002 6:00 PM
Subject: use require question


Hello,

I want to declare and initialize two variables in one script and use the
same variables in another script, like this:

script_1.pl

# use strict;
$var1 = 'foo';
$var2 = 'bar';

script_2.pl

# use strict;
require "c:/ps/scripts/test/script_1.pl";
print "In script_2.pl: $var1, $var2\n";

Executing script_2.pl gives me what I want:

In script_2.pl: foo, bar

But hey, this isn't very clean: I can't use 'use strict;' and I have to
use global variables. I've been messing around with 'local' and/or 'my'
and have got nowhere. Surely, there must be a better way...?

- jasper

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



Re: When open doesn't

2002-05-23 Thread Dirk Bremer \(NISC\)

Are you trying to open a file or a directory? If a directory, you will need
a trailing slash. If a file, you will almost certainly need to specify a
file extension. What is your E drive, attached or networked? If networked,
have you tried the UNC name?

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc
- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, May 23, 2002 13:27
Subject: Re: When open doesn't


> [EMAIL PROTECTED] wrote:
>
>
> >Change your argument to: E:/BU_0/C/Prefs
>
> >The backslash is escaping the characters it preceeds. Alternative:
>
> >E:\\BU_0\\C\\Prefs
>
> Nope.  Already done both of those (and a lot of other permutations).
> I may be a UNIX guy, but I've been in double-backslash hell enough
> to know my way out of that trap.
>
> Any other ideas?
>
>
>

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



Re: When open doesn't

2002-05-23 Thread Dirk Bremer \(NISC\)

Change your argument to: E:/BU_0/C/Prefs

The backslash is escaping the characters it preceeds. Alternative:

E:\\BU_0\\C\\Prefs

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc
- Original Message - 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, May 23, 2002 11:02
Subject: Re: When open doesn't


> Johan Lindstrom <[EMAIL PROTECTED]> wrote:
> 
> >When open doesn't, print the error message.
> 
> Actually, I did.  Its just that the system its failing on doesn't 
> have a good internet connection, and when I was describing the 
> problem,  I was typing in stuff from memory and I forgot to enter
> the code which prints $!.  The error I'm getting is "Invalid 
> Argument". (I think - I did mention it in my last post).
> 
> The file name is "E:\BU_0\C\Prefs".  That is to say:
> 
> typing:
> 
> DOS>perl test.pl E:\BU_0\C\Prefs
> 
> gets an error message:
> 
> Unable to open "E:\BU_0\C\Prefs" for reading (Invalid Argument)
> 
> and typing:
> 
> DOS>type E:\BU_0\C\Prefs
> 
> works fine (causing the contents of the file to be sent to the
> screen. I've tried doubling the backslashes, and making it all
> caps, etc.  It also works fine as is on a different Win 98 system.
> Its just failing on this one system.
> 
> Anybody got any ideas?  I'd appreciate a reply to me, not just
> the list, because I only subscribe to the digest, and its not
> really well formatted for anything but a quick scan.
> 
> Thanks,
> BB
> 
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 
> 

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



Re: Dumbass question

2002-05-22 Thread Dirk Bremer \(NISC\)

I also will do the following:

Start->Settings->Control Panel->System->Advanced tab->Environment Variables
button->System variables list, select and edit the PATHEXT variable, add
'.PL;' to the variable string, and then click Okay on everything.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc
- Original Message -
From: "Moran, Neil (LDN Corp)" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Active Perl"
<[EMAIL PROTECTED]>
Sent: Wednesday, May 22, 2002 06:05
Subject: RE: Dumbass question


> You can use the ASSOC and FTYPE commands at the command line to associate
> the .pl extension with perl.exe, and any additional parameters you may
> require, for example:
>
> ASSOC .pl=PerlScript
> FTYPE PerlScript=perl.exe %1 %*
>
> would allow you to invoke a Perl script as follows:
>
> script.pl 1 2 3
>
> If you want to eliminate the need to type the extensions, then do the
> following:
>
> set PATHEXT=.pl;%PATHEXT%
>
> and the script could be invoked as follows:
>
> script 1 2 3
>
> That should do it! The above, by the way, is ruthlessly cut'n'pasted from
> the output of the HELP FTYPE command. ;-)
>
> Neil Moran
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: 22 May 2002 11:54
> To: Active Perl
> Subject: Dumbass question
>
>
> How do you make it so that you don't have to type the '.pl' extension when
> running perl scripts on Win2k?
>
> Yes, yes, I realise I should know this...
>
> Evan Morris
> [EMAIL PROTECTED]
> Tel: +27 11 792 2777
> Fax: +27 11 792 2711


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



Re: More or Pager function is Perl

2002-05-16 Thread Dirk Bremer \(NISC\)

> I'm output a massive list to STDOUT but wish to break it like the MORE
> function in DOS.  For instance I have a huge array and for each row the
> array I'm outputting to STDOUT.  But when the output reaches the end of
the
> page, I would like to pause it.  What's the best way to do this?
>
> thanks
> Chuck

Chuck,

This is what I use in a program that mimics the Unix head command:

# After you have displayed a line, assuming that $Displayed
equals zero at
# the start of the script:

$Displayed++;

# Prompt the user each time after a block of 45 lines has been
displayed.
if (($Displayed % 45) == 0)
{
print(STDERR ' to continue with this file...');
$Prompt = ;
last if (length($Prompt) > 1);
}


Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

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



Re: deterministic regexps (missed something)

2002-03-27 Thread Dirk Bremer

Ken,

The following code used after your search might be useful:

# A regex debug structure.
use English;
if (defined $PREMATCH)  {print("PREMATCH  = $PREMATCH\n")}
if (defined $MATCH) {print("MATCH = $MATCH\n")}
if (defined $POSTMATCH) {print("POSTMATCH = $PREMATCH\n")}
if (defined $1) {print("\$1   = $1\n")}
if (defined $2) {print("\$2   = $2\n")}
if (defined $3) {print("\$3   = $3\n")}
if (defined $4) {print("\$4   = $4\n")}
if (defined $5) {print("\$5   = $5\n")}
if (defined $6) {print("\$6   = $6\n")}
if (defined $7) {print("\$7   = $7\n")}
if (defined $8) {print("\$8   = $8\n")}
if (defined $9) {print("\$9   = $9\n")}

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc


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



Re: deterministic regexps (missed something)

2002-03-27 Thread Dirk Bremer

Ken,

Why don't you post a few lines of the data that you are trying to match, especially 
the lines that match. 

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

- Original Message - 
From: "Ken Fox" <[EMAIL PROTECTED]>
To: "Perl-Win32-Users" <[EMAIL PROTECTED]>
Sent: Wednesday, March 27, 2002 15:28
Subject: RE: deterministic regexps (missed something) 


> Folks -
> 
> $check is not set following the line
> if ($line=~ =~/$megapat/ ) {
> 
> because I am trying to figure this part out -- actually, One of the issues
> I am having is that $megapat is currently matching every line in the file...
> which is not really what I intended.
> 
> Other notes - in the load config file sub, there's a line preceding the
> individual config entries showing the previoius hardcoded versions --
> 
> I think that if I can get the $megapat to match the right lines, I can wrap
> the pattern itrself in parens like Dirk suggested (I had thought of that
> too) and grab $1 for the match and do a reverse lookup again.
> 
> -- Thanks, ken

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



Re: Compress::Zlib replacement for pknunzip

2002-03-11 Thread Dirk Bremer



Here is a incomplete code example 
for Archive::Zip;
 
    use 
Archive::Zip;
    # Check that the zip archive 
exists.    unless (-e $ZipInputFile) {WriteLog("$ZipInputFile 
does not exist",0); exit(0);}
 
    # Object constructor.    $ZipObject = 
Archive::Zip->new();
 
    # Read in the zip archive.    unless 
($ZipObject->read($ZipInputFile) == 0)    
{    
SetAttr($ZipInputFile,'AHR');    
WriteLog("Cannot open zip archive 
$ZipInputFile",1);    
exit(0);    }
 
    # Determine the number of files within the zip 
archive.    $NbrMembers = 
$ZipObject->numberOfMembers();
 
    # Check that files exist within the zip 
archive.    unless ($NbrMembers > 0)    
{    
SetAttr($ZipInputFile,'AHR');    
WriteLog("$ZipInputFile is 
empty",1);    
exit(0);    }
 
    WriteLog("Number of files in archive: 
$NbrMembers",0);
 
    # Extract each file from the zip 
archive.    foreach 
($ZipObject->memberNames())    
{    # Define the output 
filename.    $ZipOutputFile = join 
'',$ZipOutputDir,$JobType,$Coop,$Cycle,$Extension;    

    # If the output filename already 
exists, attempt to delete it.    
DeleteFile($ZipOutputFile);
 
    # Extract the file into the output 
filename.    if 
($ZipObject->extractMember($_,$ZipOutputFile) != 
0)    
{    
WriteLog("Cannot extract $_ from $ZipInputFile, file may be 
corrupted",1);    
next;    }    
}
                
    
Dirk Bremer 
- Systems Programmer II - ESS/AMS  - NISC St. Peters636-922-9158 ext. 
652 fax 636-447-4471
 
[EMAIL PROTECTED]www.nisc.cc

  - Original Message - 
  From: 
  [EMAIL PROTECTED] 
  
  To: [EMAIL PROTECTED] 
  
  Sent: Monday, March 11, 2002 12:50
  Subject: Compress::Zlib replacement for 
  pknunzip
  Hi all; My apologies for the newbie type question, but the 
  perldoc on this one isn't clear to me. I want to extract a file from a .ZIP 
  archive and I think that this is the right package, but am hoping to find a 
  code snippet that I can emulate. I'm trying to replace system calls like: 
  system("pkunzip -e $zipfilename $searchfilename") which works, but may force 
  unwanted screen interactions. Thanks, John**This 
  e-mail and any files transmitted with it are considered confidential and 
  are intended solely for the use of the individual or entity to whom they 
  are addressed (intended). This communication is subject to agent/client 
  privilege. If you are not the intended recipient (received in error) or 
  the person responsible for delivering the e-mail to the intended 
  recipient, be advised that you have received this e-mail in error and that 
  any use, dissemination, forwarding, printing or copying of this e-mail is 
  strictly prohibited. If you have received this e-mail in error please 
  notify the sender 
  immediately.**


Re: clearing a variable/array

2002-02-28 Thread Dirk Bremer

$variable = undef;
@array = ();
%hash = ();

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

- Original Message - 
From: "Jose Guevarra" <[EMAIL PROTECTED]>
To: "Perl-Win32-Users" <[EMAIL PROTECTED]>
Sent: Thursday, February 28, 2002 10:52
Subject: clearing a variable/array


> HI,
> 
>  How can you clear the value of a variable or array?  
> 
> $variable = ""; ?
> @array = "" ?
> 
> or is there a special function that does this.
> 
> 
> thanx
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 
> 

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



Re: Repost: problems with elsif and $self

2002-02-22 Thread Dirk Bremer

I would like to suggest to the originator of this post that he considers one Perl's 
case-type structures instead of all of the elsif
statements:

SWITCH:
{
if (test1) {do something; last SWITCH;}
if (test2) {do something; last SWITCH;}
if (test3) {do something; last SWITCH;}
...
}

I rarely use elsif's and much prefer a case statement, which might be made more 
efficient than a series of if/elsif's.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc


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



Re: perl -P in activestate

2002-02-19 Thread Dirk Bremer

Robert,

Its been a long time since I have programmed in C, but I recall that they have 
something similar to an #ifdef, etc., so that you
would do something like:

#define DEBUG
...
#ifdef DEBUG
print("Debugging at line $x for value $y\n");
#endif

You would not have to change the syntax or names of Perl functions.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

> This is a debugging use of the preprocessor, which is not really a
> problem since only you will have to understand it.
> Would you use it to globally redefine the meaning of say "print"?  If
> you did it would severely undermine the ability of other
> programmers to understand you? Neither would I.
> If the capability was needed in the program permanently I would
> implement it by creating a subroutine say "dprint" and go between
> debug and release mode by commenting and uncommenting lines
> in this subroutine.  Although a little more work would be entailed
> whenever a new programmer saw "dprint" they would be aware that
> it isn't the normal print statement.


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



Re: Zero-suppression Regex

2002-02-18 Thread Dirk Bremer

Alistair,

The input data consists of numeric strings created in two different formats form two 
different platforms, one having leading signs
and one having trailing signs. The commify will ignore the trailing signs, which is 
fine for my requirements, unless someone wants
to propose another regex to swap the signs, i.e. either make all output strings have 
leading or trailing signs, regardless of input.
I changed my mind on the justification, the commify construct alters the length in a 
manner that could result in a string that is
longer than the input, for the program which utilizes this sub, I fould it more 
pleasant to see all of the strings left-justified,
i.e.


 1:1-4:  4:N:160 Record ID160
 2:5-9:  5:A:160 Type Of Service >COOP <
 3:  10-10:  1:A:160 Reading Activity Code   >R<
 4:  11-25: 15:A:160 Meter Number>17778  <
 5:  26-40: 15:A:160 Secondary Meter Number  >   <
 6:  41-42:  2:N:160 Position Number  1
 7:  43-47:  5:A:160 Rate Schedule   >RES  <
 8:  48-48:  1:N:160 Meter Type   0
 9:  49-51:  3:A:160 Who Read Meter Code >5  <
10:  52-52:  1:N:160 Electrical Use Code  0
11:  53-53:  1:N:160 Number Of Dials  5
12:  54-62:  9:4:160 Multiplier   1.
13:  63-71:  9:N:160 Present Reading  38,512
14:  72-79:  8:D:160 Present Reading Date 02-04-2002
15:  80-80:  1:A:160 Present Reading Code>0<
16:  81-89:  9:N:160 Previous Reading 38,140
17:  90-97:  8:D:160 Previous Reading Date01-09-2002
18:  98-98:  1:A:160 Previous Reading Code   >0<
19: 99-107:  9:S:160 KWH Usage372+
20:108-116:  9:S:160 Revenue  40.14+
21:117-125:  9:4:160 KVAR Multiplier  0.
22:126-134:  9:2:160 KVAR Previous Reading0.00
23:135-143:  9:2:160 KVAR Present Reading 0.00
24:144-152:  9:S:160 KVAR Usage   0.00+
25:153-172: 20:A:160 Map Location>162-24-18   <
26:173-174:  2:N:160 Register Number  1
27:175-179:  5:N:160 Reading Number   0
28:180-180:  1:A:160 End Of Record   >X<


Based upon a suggestion from $Bill on argument handling, the latest revision is:

sub ZeroSuppress($;$)
{
local $_ = $_[0];

# If the argument for the decimal point exists, insert a decimal point
# at the specified location.
s/(\d{$_[1]})([-+]?)$/\.$1$2/ if ($_[1]);

# Zero-suppress the string.
s/\b0+(?=\d)//;

# Remove leading spaces.
s/([-+]?)\s*/$1/;

# Insert comma separators.
    1 while s/^([-+]?\d+)(\d{3})/$1,$2/;

return($_);
}

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc



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



Benchmark Error

2002-02-14 Thread Dirk Bremer

When I benchmark using this code:

{
sub test1($)
{
my $self = shift;
return($self =~ s/^\s+//);
}

sub test2($)
{
my $self = shift;
while (substr($self,0,1) eq ' ') {$self = substr($self,1);}
return($self);
}

use Benchmark;
timethese(100,{'regex'=>test1('1.11'),'substring'=>test2('1.11')});
exit(1);
}

I get this error:

Benchmark: timing 100 iterations of regex, substring...
 regex:  0 wallclock secs ( 0.15 usr +  0.00 sys =  0.15 CPU) @ 6622516.56/s 
(n=100)
(warning: too few iterations for a reliable count)
Useless use of a constant in void context at (eval 5) line 1 (#1)
(W void) You did something without a side effect in a context that does
nothing with the return value, such as a statement that doesn't return a
value from a block, or the left side of a scalar comma operator.  Very
often this points not to stupidity on your part, but a failure of Perl
to parse your program the way you thought it would.  For example, you'd
get this if you mixed up your C precedence with Python precedence and
said

$one, $two = 1, 2;

when you meant to say

($one, $two) = (1, 2);

Another common error is to use ordinary parentheses to construct a list
reference when you should be using square or curly brackets, for
example, if you say

$array = (1,2);

when you should have said

$array = [1,2];

The square brackets explicitly turn a list value into a scalar value,
while parentheses do not.  So when a parenthesized list is evaluated in
a scalar context, the comma is treated like C's comma operator, which
throws away the left argument, which is not what you want.  See
perlref for more on this.

 substring:  0 wallclock secs ( 0.14 usr +  0.00 sys =  0.14 CPU) @ 7142857.14/s 
(n=100)
(warning: too few iterations for a reliable count)

I assume that the error is coming from the test2 sub. When run without the benchmark, 
I get no errors. Why does test2 generate this
error?

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc


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



Re: Zero-suppression Regex

2002-02-14 Thread Dirk Bremer

Here is a quicker version of the zero-suppression routine that will also float a 
leading sign character:

sub ZeroSuppress2($)
{
my $self = shift;

# Return if the argument is less than two digits.
return($self) if (length($self) < 2);

# Search for a embedded decimal point.
my $decimal  = rindex($self,'.');

# If the decimal point exists, substract one from its position
# to define the end point of the zero-suppression, else determine
# the entire length of the string and subtract one to define the
# end point of the zero-suppression.
if ($decimal > 0) {$decimal-- ;}
else {$decimal = length($self) - 1;}

# Iterate through the list suppressing leading zeroes.
my $i;
my $c;
for ($i = 0; $i < $decimal; $i++)
{
$c = substr($self,$i,1);
# Skip to the next character if the current character is a
# plus-sign, minus-sign, or space.
next if ($c eq ' ' or
 $c eq '+' or
 $c eq '-');

# Terminate the loop if the current character is s digit.
last if ($c > 0);

# Replace the zero in the current character with a space.
substr($self,$i,1) = ' ';
}

$c = substr($self,0,1);
# Check for a leading sign-character.
if ($c eq '+' or $c eq '-')
{
# If the list has more two elements, move the sign-character
# from the leftmost position to the position of the rightmost
# space character.
if ($i > 1) {substr($self,$i - 1,1) = $c; substr($self,0,1) = ' ';}
}

return($self);
}

After running some more benchmarks, this routine is several orders of magnitude faster 
than sprinf or a regex. 

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc


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



Re: Cobol Data conversion using Perl

2002-02-13 Thread Dirk Bremer

Steve,

How funny you should mention that, I come from a COBOL background and find printf to 
be difficult to use compared to an edited PIC
clause. In fact, maybe that's an idea for a module...

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

> I frequently use named pipes from COBOL programs to perl programs as a way
> to get data back and forth, write Excel files, etc.  It's almost like a
> time machine to 1980!  Its kind of funny, but I was following the 'zero
> suppression regex' thread the last day or two thinking "easy enough with a
> COBOL picture clause!".
>
> Good luck!
>
> Steve


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



Re: Cobol Data conversion using Perl

2002-02-13 Thread Dirk Bremer

I would first determine if the .dat file extension is the file that contains the 
actual data. You are fortunate that in the FD there
is not any type of packed (COBOL) data. In fact, you should always insist that the 
data contain no packed fields, just straight
ASCII data. Next, depending on which platform the data file was created, I would dump 
the file in a hex viewer to see if there is
any blocking and/or record length information preceding each data record and if there 
are any record termination characters, i.e.
CR/LF, etc. On some platforms, specifying LABEL RECORDS ARE OMITTED in the FD can help 
produce a fixed-record-length file will no
block information. Should the file have blocking and/or record length specification 
(more common on variable length records), you
will need to decode this information to figure out how many bytes to read at a time. 
For example:

while (read(InputFileHnd,$RecordLength,2))
{
# Convert the binary characters to an integer which represents the
# length of the record to be read.
$RecordLength = unpack("v4",$RecordLength);

# Read the input file for the calculated number of characters.
read(InputFileHnd,$OutputLine,$RecordLength);

# If the record length is an odd number, read and discard one byte
# that is used by OpenVms to pad odd length records with a
# binary zero.
if (($RecordLength %2) == 1) {read(InputFileHnd,$Padding,1);}

$LinesRead++;

print(OutputFileHnd "$OutputLine\n");
$LinesWritten++;
Statistics("Lines");
}

The above code is used to read a DEC OpenVMS RMS file that has no record termination 
characters and a two-byte record length
specification at the beginning of each record. It reads two-bytes, computes the record 
length, and then reads the record length
number of bytes.

If the file has fixed-length records with no record termination, then you can read the 
file with:

while (read(FH1,$_,$InputLength))

where the $InputLength variable would be set or substituted for the actual record 
length value. After reading the record, I have
find the easiest way to parse the record into individual fields is to:

@Record = unpack 'a35 a30 a10 a10 a30 a12 a30 a12 a2 a10 a70 a70 a75',$_;

The above is layed out for your record. Then you could write to your output file like:

for (@Record) {print(OFH,"$_,");}
print(OFH,"\n");

The above assumes that what ever you use to parse the output file is tolerant of 
having a comma following the last data field,
otherwise you will have to process the array in a slightly different manner to exclude 
the last comma.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

- Original Message -
From: "Pereira, Jude (Jude)** CTR **" <[EMAIL PROTECTED]>
To: "'Tillman, James'" <[EMAIL PROTECTED]>; 
<[EMAIL PROTECTED]>
Sent: Wednesday, February 13, 2002 09:40
Subject: RE: Cobol Data conversion using Perl


> I should have given more information in my earlier email.
> Sorry about that.
>
> Here is the structure of one data file (AGENT.WKS)
>
>
>   03 AGENT-L-NAME-SSPIC X(35).
>   03 AGENT-F-NAME-SSPIC X(30).
>   03 AGENT-ID1-NUM-SS   PIC X(10).
>   03 AGENT-ID2-NUM-SS   PIC X(10).
>   03 AGENT-ADDRESS-SS   PIC X(30).
>   03 AGENT-PHONE-1-SS   PIC X(12).
>   03 AGENT-CITY-SS  PIC X(30).
>   03 AGENT-PHONE-2-SS   PIC X(12).
>   03 AGENT-STATE-SS PIC XX.
>   03 AGENT-ZIP-SS   PIC X(10).
>   03 AGENT-COMMENT-1-SS PIC X(70).
>   03 AGENT-COMMENT-2-SS PIC X(70).
>   03 AGENT-ERROR-SS PIC X(75).
>
>
> And the FD file (AGENT.FD) contains
>
>FD AGENT-FILE RECORD CONTAINS 339 CHARACTERS
>   LABEL RECORDS ARE STANDARD.
>
>
> I have the following files for each data file.
>
> .WKS, .SS, .SRN, .IDX, .FD, 
>.DAT, .CPY
>
> Please let me know if you need additional information
>
> Thanks,
> Jude
>
> -Original Message-
> From: Tillman, James [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 13, 2002 10:04 AM
> To: 'Pereira, Jude (Jude)** CTR **';
> '[EMAIL PROTECTED]'
> Subject: RE: Cobol Data conversion using Perl
>
>
> > I have some Cobol data which I would like to convert to csv
> > format using PERL.
>
> Cobol data?  What's the format of the data?  Is it fixed length?  If so,
> check out Perl's pack/unpack functions.  They are ve

Re: Zero-suppression Regex

2002-02-12 Thread Dirk Bremer

Alistair,

No need to fall off of the horse, you will get bruised that way. Sometimes you have to 
point your horse in a different direction to
view the horizon. Note the following:

{
use Benchmark;
timethese(10,
 {'sprintf' => sub {my $num = '0.00';$num = sprintf('%1.2f',$num);},
  'regex'   => sub {my $num = '0.00';$num =~ s/\b0+(?=\d)//;}});
}

returns:

Benchmark: timing 10 iterations of regex, sprintf...
 regex:  2 wallclock sec ( 2.30 usr +  0.00 sys =  2.30 CPU) @ 43402.78/s 
(n=10)
   sprint:  3 wallclock secs ( 2.39 usr +  0.00 sys =  2.39 CPU) @ 41788.55/s 
(n=10)

I was quite surprised to see that the regex won out by a bit, I would have thought 
that it would have invoked more overhead. This
has been a learning experience, which is one of the aspects of this list that I enjoy.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc


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



Re: Zero-suppression Regex

2002-02-12 Thread Dirk Bremer

In my instance, the 0+ solution would not produce the results I desire. For example, 
imagine the input string is "000.00" as in
a dollar amount. The result I desire is "0.00", while the 0+ method results in "0". 
The regex that Joe provided produced my desired
result, while the 0+ maybe useful for other things.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 12, 2002 11:36
Subject: RE: Zero-suppression Regex


> As Michael G Schwern over on the Fun With Perl group said:
> > Folks, I'm clawing my eyes out here.  Stop hitting the regex crack
> pipe!
>
> Although he was specifically talking about printf vs a regex for zero
> padding numbers, the principle still applies. Perl has an incredibly
> efficient "convert number-like text into a proper number" function. It works
> implicitly every time you use a numerical operator on a scalar. The regex
> tool is comparatively slow and an all-purpose, robust solution is
> non-trivial.
>
> Why not just use 0+$_ and let perl work its magic. I challenge any of you
> regex "pushers" out there to write a regex that beats this in either speed
> or elegance.
>
> BTW Joe's solution s/^-?0+(?=\d)// will fail for negative numbers. I would
> post a fix but I appear to be on my high horse at the moment :-)


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



Regex for comma substitution

2001-12-21 Thread Dirk Bremer

I am looking for a regex to be used for comma substitution for numbers, i.e. the regex 
would transform:

999 = 999
   = 9,999
9 = 99,999
99   = 999,999
999 = 9,999,999, etc.

I tried s/(\d{3})/,$1/g, but for certain numbers it leaves a leading comma, i.e. 
99 = ,999,999. Please advise.

Dirk Bremer - Systems Programmer II - AMS Department - NISC
636-922-9158 ext. 652 fax 636-447-4471

<mailto:[EMAIL PROTECTED]>


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



Minimize Window

2001-11-28 Thread Dirk Bremer

I have started an instance of the Winnt Task Manager using Win32::Process, and once it 
has started, I would like to minimize it. How
may I accomplish this in Perl?

Dirk Bremer - Systems Programmer II - AMS Department - NISC
636-922-9158 ext. 652 fax 636-447-4471

<mailto:[EMAIL PROTECTED]>


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



Re: directory again

2001-05-31 Thread Dirk Bremer

$#ARGV contains the number of arguments minus one in @ARGV, i.e. the first argument is 
$ARGV[0]. Sample code:

# Check that the required number of arguments have been passed.
if ($#ARGV < 0)
{
Help();
$InputFile = GetUserInput('Enter the input filename',0);
}
else {$InputFile = $ARGV[0];}

# Check for optional second argument.
if ($#ARGV > 0) {$NbrPages = $ARGV[1];}

# Check for optional third argument.
if ($#ARGV > 1) {$Width = $ARGV[2];}
else {$Width = 80}

In the above code, if no arguments were entered on the command line, the Help() 
function will be called, else the $InputFile will be
assigned the first argument. If there is more than one argument, $NbrPages will be 
assigned the second argument. If there is more
than two arguments, $Width will be assigned the third argument, etc. For options 
(flags) such as -d, check out the Getopt module.
For example:

use Getopt::Std;
# Check if the -h option was entered.
our $opt_h;
getopts('h');

# If the -h option was entered, print the help and exit the program.
if (defined $opt_h)
{
Help();
exit(1);
}

In the above code, it is checking for a -h option to be entered. Note that you must 
declare a variable for each option. So if we
use -d and -h as options, we would need to change the our statement above to be 
something like:

our ($opt_d,$opt_h)

You can then simply test if they are defined to determine whether or not they have 
been entered. All of this information is in the
Camel book, if you don't have it, get it, if you have it, please read it.

Dirk Bremer - Systems Programmer II - AMS Department - NISC
636-922-9158 ext. 652 fax 636-447-4471

<mailto:[EMAIL PROTECTED]>

- Original Message -
From: "Tanya Graham" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 31, 2001 4:02 PM
Subject: RE: directory again


> Does anyone know where I can find information on passing parameters (flags)
> on the command line?
> thank you
> tanya
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 31, 2001 9:13 AM
> To: '[EMAIL PROTECTED]'
> Subject: Re: directory again
>
>
>
> >Hi,
> >I need to be able to recursively go through a directory and if i encounter
> a
> >file folder, perform the same actions on the files in that file folder.
> is
> >there a simple way to do this, like with an if-statement?
> >thanks
> >tanya graham
>
> Tanya,
>
> Please try to avoid replying with someone else's post, and just changing
> the subject, it's confusing.
>
> Everyone here seems to have gone far out of their way to respond to your
> earlier directory dilemma, including me, so allow me to now voice a few
> suggestions.
>
> From your previous post, and this one I think it's fair to assume you are
> very new to perl.  The reason I like this mailing list so much is that they
> are very kind to newbies, and I've never seen a flame war on this list.
> Being new, it's often easy to not even know where the documentation is.
> First, check the FAQ's, they are installed in HTML format when you install
> ActiveState perl, many "easy" problems can be resolved right there.  Many
> people in response to your previous post pointed towards perldoc (perldoc
> -f opendir ) as a tool to find information about function and module usage.
> Another tool is PPM, which you can use to search for modules and install
> them from ActiveState's (or any other ) ppm repository.  Often it's good to
> run a search for what you're looking for through there (such as "dir" or
> "file" in your case), install a few "likely" sounding packages and then run
> perldoc on them to see if they offer the features you are really looking
> for.  You can type "help" in ppm for usage help, and perldoc perldoc will
> give you more than you ever wanted to know about how to use perldoc.  Also
> look at the O'Reilly series of perl books, as they are invaluable
> resources.  You can find info on them at www.perl.com.  I apoligize to all
> for this long post, but while I think none of us has a problem helping, I
> personally have a problem when someone doesn't help themself first.
>
> To answer your current question, you may want to take a look at the
> File::Find module as this will recurse through a directory tree and can
> perform a specified callback (subroutine) on each file it finds.
>
> Sorry for the long post,
>
> Chuck
>
>
>
> ___
> 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
>
>

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



Re: filetest operators

2001-05-16 Thread Dirk Bremer

use Win32::File qw(:DEFAULT GetAttributes SetAttributes);
my %Constants = ('A' => ARCHIVE,
 'C' => COMPRESSED,
 'D' => DIRECTORY,
 'H' => HIDDEN,
 'N' => NORMAL,
 'O' => OFFLINE,
 'R' => READONLY,
 'S' => SYSTEM,
 'T' => TEMPORARY);
my $Attr  = 0;

# Get the file attributes.
GetAttributes($File,$Attr);

# Equate the numeric attributes to alpha to A, H, R, S, etc.
foreach (keys %Constants)
{
    if ($Attr & $Constants{$_}) {$Attrs .= $_;}
}

$File would be assigned your file name/directory name.

Dirk Bremer - Systems Programmer II - AMS Department - NISC
636-922-9158 ext. 652 fax 636-447-4471

<mailto:[EMAIL PROTECTED]>


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



Translating Characters

2001-04-11 Thread Dirk Bremer

I would like to do something simple with a ^, |, or & to translate sign-overstruck 
characters to their corresponding numeric values
and vice versa. For example, the sign-overstruck characters equals the following 
numbers:

{ = -0
A = -1
B = -2
C = -3
D = -4
E = -5
F = -6
G = -7
H = -8
I = -9

How can I do this with Perl's bitwise operators?

Dirk Bremer - Systems Programmer II - AMS Department - NISC
636-922-9158 ext. 652 fax 636-447-4471

<mailto:[EMAIL PROTECTED]>


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



Re: Optional Arguments

2001-04-10 Thread Dirk Bremer

Joe,

I changed things to pass undef as the third argument and to just check for defined on 
the argument and it works fine. Thanks for
your and others' suggestions on this issue.

Dirk Bremer - Systems Programmer II - AMS Department - NISC
636-922-9158 ext. 652 fax 636-447-4471

<mailto:[EMAIL PROTECTED]>

- Original Message -
From: "Joe Schell" <[EMAIL PROTECTED]>
To: "Dirk Bremer" <[EMAIL PROTECTED]>
Cc: "perl-win32-users" <[EMAIL PROTECTED]>
Sent: Tuesday, April 10, 2001 9:40 AM
Subject: Re: Optional Arguments


> Even given the above you might want to use the following instead
>
>   Depth($Dir,\%Files,undef,15);
>
> That might indicate more clearly that no value is being passed in.
>
> This allows you to just test for defined or not and skip all of the
> array bounds checking.
>
> if (defined($_[2])) {$Type = $_[2];}
>
>

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



Re: Optional Arguments

2001-04-10 Thread Dirk Bremer

Joe,

Some clarification, the first two arguments are always required. Both the third 
argument and fourth argument are optional and
positional. There would be instances where the fourth argument would have a valid 
value but the third argument would have some type
of null value to indicate that it would not be used. I have tried passing under, "", 
'', " ", and ' ' as the third argument and
testing for its presence and validity. For example, when called like this:

Depth($Dir,\%Files,'',15);

The third argument is a null string. The check:

if ((@_ > 1) and (defined $_[2])) {$Type = $_[2];}

equates to being true and sets $Type. The check:

if ((@_ > 1) and (length($_[2]))) {$Type = $_[2];}

generates the error but seems to equate to false and $Type is not set. I would like 
someway to test this argument without generating
an error and generating a false condition in a validity check for the value used in 
the example.

Dirk Bremer - Systems Programmer II - AMS Department - NISC
636-922-9158 ext. 652 fax 636-447-4471

<mailto:[EMAIL PROTECTED]>

- Original Message -
From: "Joe Schell" <[EMAIL PROTECTED]>
To: "Dirk Bremer" <[EMAIL PROTECTED]>
Cc: "perl-win32-users" <[EMAIL PROTECTED]>
Sent: Monday, April 09, 2001 11:29 PM
Subject: Re: Optional Arguments


> Your example is passing four arguments not two which makes your question
> rather confusing.
>
> But presuming you meant this
>
>  Depth($Dir, \%Files)
>
> This works:
>
>  if (scalar(@_) > 2)
> {
> # Do something with param 3
> }
>   if (scalar(@_) > 3)
> {
> # Do something with param 3
> }
>
> So does this:
>
>   if (defined($_[2]))
> {
> # param 3 defined
> }
>
> If you did this and still got errors then I would suspect that you had
> something else wrong with your code.
>
>

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



Grep Help

2001-04-04 Thread Dirk Bremer

Sorry if you get this message twice, but I don't think it made it out the first time.

I was following the thread glob vs. readdir and changed one of my scripts to readdir:

# Clean-up the job/coop's directories.
foreach $ForVar1 ("ctr","e??","frm","fmx","i??","lgo")
{
unless (chdir("$RootDir/$Coop/$JobName/$CoopDir/")) {next;}
opendir(GLOB,".") or die "Cannot open current directory $!, stopped";
@Result = grep /\.$ForVar1/, readdir(GLOB);
closedir(GLOB);
if (@Result)
{
foreach $ForVar2 (@Result)
{
del("!q $ForVar2");
}
}
}

I am having a problem with the grep function. It returns all of the files in the 
directory instead of the specified file extensions.
It appears that grep does not recognize the value in $ForVar1. Any suggestions?

Dirk Bremer - Systems Programmer II - AMS Department - NISC
636-922-9158 ext. 652 fax 636-447-4471

<mailto:[EMAIL PROTECTED]>


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



PerlCheck Program

2001-04-04 Thread Dirk Bremer

I have a new version of my PerlCheck program available. I also wrote a program that 
will calculate voltage drops for 120AC lines.
Email me direct if you are interested in either of these programs and indicate if you 
would like the files as attachments or inline.

Dirk Bremer - Systems Programmer II - AMS Department - NISC
636-922-9158 ext. 652 fax 636-447-4471

<mailto:[EMAIL PROTECTED]>


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



  1   2   >