Re: Calling SetWindowsHookEx()?

2006-06-19 Thread Lyle Kopnicky

Veli-Pekka Tätilä wrote:

Lyle Kopnicky wrote:

I'm trying to capture keyboard events using SetWindowsHookEx(). I've
tried to set this up using the Win32::API and Win32::API::Callback
modules. But I'm not getting any events.

Umm, according to MSDn docs your hook code must be in a DLL. See:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/html/msdn_hooks32.asp 

Thanks for the info. It appears the code only needs to be in a DLL if 
you want to create a system level hook. I only need a thread level hook.


The key thing I need help with now is the Perl. Listed below is what I 
have so far. It waits for a few seconds, then quits. If I change the 
return type of SetWindowsHookEx from 'P' to 'N', my main window will 
open, but I still don't get any calls to KeyboardHook. It may just be a 
matter of specifying the wrong types for the Win32 functions. Any ideas? 
Thanks.


use warnings;
use strict;
use Tk;
use Win32::API;
use Win32::API::Callback;

my $WH_KEYBOARD_LL = 13;

my $GetCurrentThreadId
   = new Win32::API('kernel32', 'GetCurrentThreadId', '', 'N');
my $SetWindowsHookEx =
   new Win32::API('user32', 'SetWindowsHookEx', 'NKPP', 'P');
Win32::API->Import('user32', 'HHOOK SetWindowsHookEx(int idHook, 
HOOKPROC lpfn, HINSTANCE hMod, DWORD dwThreadId)');

my $CallNextHookEx =
   new Win32::API('user32', 'CallNextHookEx', 'PNNN', 'N');
  
sub KeyboardHook($$$) {

   my ($nCode, $wParam, $lParam) = @_;
  
   print "nCode=$nCode, wParam=$wParam, lParam=$lParam\n";

   $CallNextHookEx->Call(0, $nCode, $wParam, $lParam);
}

my $KeyboardHookCallback =
   new Win32::API::Callback(\&KeyboardHook, 'NNP', 'N');
my $ThreadId = $GetCurrentThreadId->Call();
my $Hook = $SetWindowsHookEx->Call($WH_KEYBOARD_LL, $KeyboardHookCallback,
   0, $ThreadId);

my $win = MainWindow->new();
MainLoop();

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


Calling SetWindowsHookEx()?

2006-06-18 Thread Lyle Kopnicky

Hi folks,

I'm trying to capture keyboard events using SetWindowsHookEx(). I've 
tried to set this up using the Win32::API and Win32::API::Callback 
modules. But I'm not getting any events. Any ideas? Here's my code:


use warnings;
use strict;
use Tk;
use Win32::API;
use Win32::API::Callback;

my $WH_KEYBOARD_LL = 13;

sub KeyboardHook($$$) {
   my ($nCode, $wParam, $lParam) = @_;
   
   print "nCode=$nCode, wParam=$wParam, lParam=$lParam\n";

}

my $win = MainWindow->new();
my $SetWindowsHookEx =
   new Win32::API('user32', 'SetWindowsHookEx', 'IKPP');
my $KeyboardHookCallback =
   new Win32::API::Callback(\&KeyboardHook, 'NNP', 'N');
$SetWindowsHookEx->Call($WH_KEYBOARD_LL, $KeyboardHookCallback, 0, 0);

MainLoop();

--
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: Block Alt+TAB?

2006-06-15 Thread Lyle Kopnicky




Chris Wagner wrote:

  At 02:56 PM 6/14/2006 -0700, Lyle Kopnicky wrote:
  
  
Application security prevents them from running their own software.

  
  
What about creating a text file and saving it as a batch file on the desktop
and then double clicking on that?

There is no desktop. There is a personal folder where they can save
files. They can also save them on removable media. However, they don't
have permission to run cmd.exe.

They could also go to a special website
to download a batch file onto the desktop.  Or is the desktop protected by
filesystem perms.  What about the cache directory?

Another thing u can do is modify the Alt-Tab dialog so that nothing shows up
except the lockup app.  Or nothing at all for that matter.  Notice how
Explorer as taskbar doesn't show up but all the child explorers do.
  

OK, how would I do that, in Perl?
-- 
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: Block Alt+TAB?

2006-06-15 Thread Lyle Kopnicky

Chris Wagner wrote:

What about creating a text file and saving it as a batch file on the desktop
and then double clicking on that? 
The reason there's no desktop is, they don't have permission to run 
explorer.exe.


--
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: Block Alt+TAB?

2006-06-14 Thread Lyle Kopnicky




Timothy Johnson wrote:

  Does it have to be a custom screensaver?  I was thinking you could just
have your program send the SC_SCREENSAVE Windows Message and initiate
the screensaver.  Then Windows can do the "locking" for you.  It will
probably also be more secure.  I'm not sure what the requirements are
for your project, though.  
  

It would have to be a custom screensaver. It needs to do such things as:

  Show a custom message
  Show a countdown timer (how much time they have to unlock the
screen before they are automatically logged out)
  Let them type in a password to unlock, which not a Windows
password, but verified by communication with the server component of
our product

These are all things which our screen lock feature currently does, and
does well. In fact, if it were a separate program, we'd have a hard
time keeping it in sync with our timer (which can be remotely changed
on the fly).

So, I figure it's much easier to figure out how to disable a few
keystrokes, than it is to basically rewrite this part of our software
from scratch, and try to solve the resulting interoperability issues.
Remember, this is an established product, not a brand new development.
-- 
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: Block Alt+TAB?

2006-06-14 Thread Lyle Kopnicky

DePriest, Jason R. wrote:

Are you doing something like a kiosk system?

Something like that, yes.

If so, my company used something like that in the past.  It was
actually a Windows system and the only thing that could run was the
web browser.
You can run more than the browser on ours - you can also run e-mail and 
Office apps.

I think they used the Windows and IE Zero Admin Kits to accomplish it,
but all those do is automate registry and configuration changes.
Don't worry, it's an established system and things are quite well locked 
down, through security templates, file security, Application Security, 
etc. We have just developed a new add-on program, that needs, at some 
point, to be able to "lock" the screen. It's already a working product, 
been in use for a while. We just found this loophole and want to close it.

I will try to find out from one of the engineers what exactly they did
if this is the direction you are trying to go.
Thanks. If they know how to block Alt+Tab or Ctrl+Alt+Esc through a 
registry setting, that would be fine, too.


--
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: Block Alt+TAB?

2006-06-14 Thread Lyle Kopnicky

Timothy Johnson wrote:

Hmm.  Can they do Ctrl+Alt+ESC, or Win+D?
  
They can't do Win+D, but they can do Ctrl+Alt+Esc - thanks for pointing 
out another key combination that is a problem. I'll want to block this, too.

Other than somehow loading their own code onto the system, I can't think
of anything off the top of my head.  Couldn't you just launch a
screensaver to lock the screen?  It just seems like if your process is
running in the user context somebody could find some way around it.
  
Can you give me an example of how to write a screensaver in Perl? We 
already have a very nicely working window. Making a screensaver sounds a 
lot more complicated that simply blocking some key combination. Besides 
the fact that we already have a screensaver on the system, and would 
have to figure out how to alternate between this one and that one on the 
fly.


--
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: Block Alt+TAB?

2006-06-14 Thread Lyle Kopnicky

Ng, Bill wrote:

FYI  ++ will launch the task manager ... not
++.
  
Right. Ctrl+Shift+Esc doesn't work on our system. The user does not have 
access to the Task Manager. So not a problem.


As for Ctrl+Alt+Esc, this sends a window to the back, which is a problem 
for us. We would like to block that, too.


--
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: Block Alt+TAB?

2006-06-14 Thread Lyle Kopnicky

Veli-Pekka Tätilä wrote:

Hi Timothy et al,
I would say that trying to lock the computer programmatically like 
this, without using OS specific means is generally a bad idea. As long 
as your users can outsmart you in at least one way.

OK, any OS-specific means you would suggest?

Timothy Johnson wrote:

Hmm.  Can they do Ctrl+Alt+ESC, or Win+D?

or alt+esc for that matter.

Nope, they can't do Alt+Esc, either.
Access to the taskkill program in XP or setting focus to task manager 
by windows+r,

Nope, they can't do Win+R.
taskmgr would be fatal, too. Or a user simply bringing their own task 
manager with them on removable media, and written in PErl for good 
measure.

Application security prevents them from running their own software.

--
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: Block Alt+TAB?

2006-06-13 Thread Lyle Kopnicky

Timothy Johnson wrote:

Are you sure that's what you want to do?  There are other ways to get
around what you're trying to do.  What's to stop them from killing it in
Task Manager, for example?
  
It's a tightly controlled system. They can run the Windows Security 
dialog, but the only options are Log Off and Cancel, so they can't get 
to Task Manager. There is no Start button, either, so no Ctrl+ESC. Can 
you think of any other ways for them to get around it?


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


Block Alt+TAB?

2006-06-13 Thread Lyle Kopnicky

Hi folks,

What's the easiest way to block Alt+Tab (and Alt+Shift+Tab) an 
application? I am using ActivePerl 5.8.4 and Tk. I am implementing a 
"screen lock" feature by creating a window that fills the screen and 
stays on top. Unfortunately, using Alt+Tab, someone can set the focus to 
another window (although it will remain unseen). So, I need to block 
that key combination, while my "screen lock" is in force.


I read that you can block Alt+Tab using the Win32 RegisterHotKey() 
function. However, I'm weak on how to call Win32 stuff from Perl. Could 
anyone give me a simple example of how to use this to capture and ignore 
Alt+Tab and Alt+Shift+Tab? Thanks.


--
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: Program with popup won't exit

2006-05-26 Thread Lyle Kopnicky

Lyndon Rickards wrote:

# The delay here is to allow widget to render before forcing
# to front - workaround to avoid 'UpdateWrapper: Failed to create 
container'

# crash from some (mostly XP) clients
$MW->after(500,sub {$MW->stayOnTop});

Interesting... I fixed that problem differently, by writing:

   $Tk::VERSION = 800.024;

at the top of the file, just below the 'use' statements. The problem 
didn't happen with older versions of Tk::StayOnTop.


--
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: Program with popup won't exit

2006-05-25 Thread Lyle Kopnicky

Lyndon Rickards wrote:

My instinct is to give up and try something different
Yes, your "something different" works fine. I think I will work with 
that. Dunno why Tk::Dialog doesn't behave as nicely. Thanks.


--
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: Program with popup won't exit

2006-05-25 Thread Lyle Kopnicky

Jack D. wrote:

To kill a timer you just use the cancel method on the id returned when you
create the timer.
  
Thanks, I've tried that. I still get one "after" error, but it doesn't 
keep repeating. The program still doesn't exit.

If you want to do this before exiting then put it under the OnDestroy hook.
  

Well, I've already got a point in the code that explicitly exits.

Also I always end my Tk programs using $mw->destroy. This way you can run
the code after the MainLoop if needed. It also avoids namespace problems.
Tk::exit vs. CORE::exit.
  

I tried that too - it still didn't exit the program.

Jack
PS. I couldn't find the original message on this thread. Is this still the
"in your face" notice that you wanted to have Lyle? 
  

Yes.

--
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: Program with popup won't exit

2006-05-25 Thread Lyle Kopnicky

Lyndon Rickards wrote:

Lyle Kopnicky wrote:

Hi folks,

I'm having trouble with popup dialogs. If there's one open, it seems 
the program won't close. That's not good, because I need to be able 
to automatically end the program at a certain time, even if the user 
hasn't responded to the dialog. I made a toy example below. Every 
time the program tries to quit, it just generates


 Tk::Error: 0
  ("after" script)
I've faced similar when a Toplevel isn't destroyed at exit time. Using 
Tk::exit on place of exit() seems

not to help.

Yep, just tried that too, doesn't help.
Your problem appears compunnded by the repeat() - from which the 
'after...' error

is generated.
Yes. How do I cancel the repeat()? I wonder what's keeping the program 
running? In the case the popup dialog isn't being displayed, an 'exit' 
works fine - so you wouldn't think it's the repeat() that's causing the 
problem.
No help - except this thought assuming what you are trying to achieve 
is linked

to your last question -

You might use the module  Tk::Splashscreen, or at least take a look at 
the module code.

Thanks, I'll look at it.

Perhaps
the splashscreen, especially with overridedirect set to remove frame 
and controls, will go some way to

getting where you want to be?
I don't want to remove controls. I would like an OK button so the user 
can dismiss it.


--
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: Perl -pi -e 'regex'

2006-05-24 Thread Lyle Kopnicky

Adam R. Frielink wrote:

I've had some trouble with a commandline syntax for a string search and
replace using a perl command line.

My cmd line was:

perl -pi -e 's!\xae!\&\#169!g' 

This did not replace the occurace hex EA

The script for what that above cmd line should compile into (according
to the Camel Book) is:
  

...

s/\xae/\&\#169\;/g;

  

...

Running this actual script works, but not the commandline version.  Did
I not escape the commandline properly?
  

Looks like you forgot the \; in the command line.

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


Program with popup won't exit

2006-05-24 Thread Lyle Kopnicky

Hi folks,

I'm having trouble with popup dialogs. If there's one open, it seems the 
program won't close. That's not good, because I need to be able to 
automatically end the program at a certain time, even if the user hasn't 
responded to the dialog. I made a toy example below. Every time the 
program tries to quit, it just generates


 Tk::Error: 0
  ("after" script)

I tried using $window->destroy() instead of exit 0. Then the window will 
close, but the program won't exit - no errors, nothing. Any ideas? Thanks.


-

use strict;
use warnings;
use Tk;
use Tk::Dialog;

my $window = MainWindow->new();
$window->repeat(1000, sub { Quit() });
my $popup = $window->Dialog(-title => "Popup", -text => "Oh yeah!");
$popup->Show();

MainLoop();

sub Quit() {
   print "Quitting...\n";
   exit 0;
}

--
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: A system modal dialog box?

2006-05-19 Thread Lyle Kopnicky

Jack D. wrote:

-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On 
Behalf Of Lyle Kopnicky

Sent: May 18, 2006 6:41 PM
To: Perl-Win32-Users@listserv.ActiveState.com
Subject: A system modal dialog box?

Hi folks,

I need to create a dialog box in my application that prevents 
the user from doing anything else on the system until OK is 
clicked. That is, the user may not interact with any other 
windows, of any applications, during this time. It would be 
best if the dialog box was asynchronous, so the application 
could continue to process timer signals while waiting for the 
user to click OK.



Is that the only choice you are offering? One "OK" button? Why would you
need to stop all applications from being accessed to just to press a button?
  
The end-users have a time limit to use the system. They are shown a 
clock which tells them how much time they have left. At a certain point 
it changes color to warn them of the impending end-of-session. At a 
later point it starts beeping to indicate the imminent end. But 
apparently, end-users are ignoring these things and complaining they 
didn't get a proper warning, losing all their work. Our customers have 
asked for a "popup" warning, which they feel would be more 
"in-your-face". If it's modal, and the user can't do anything else, 
they're forced to acknowledge they received the warning.



I would rethink what you *really* need here. Perhaps you could describe a
bit more about *why* you need to lock out all applications :-)

  
It was not my choice to add a modal dialog box, and will be an optional 
feature in the product. Our customers are demanding this. If you can 
think of any other way to convince the customers to forgo the modal 
dialog box, let me know.

I personally hate modal dialogs - there are usually better ways to present
information to your users - or to get data input. Having been on the user
end of modal dialogs for years - most people have become immune to the
constant hassle of having to click on an OK button, only to just to continue
on with user-interaction. At a bare minimum it should offer the user a
choice.

  
If it's a constant hassle, then they're not immune. What choice should I 
offer them? OK or not OK? The session is going to end in 5 minutes no 
matter what they say

Read a bit more about modal dialogs.

Alan Cooper (father of Visual Basic)has written what I consider to be a very
scathing book (About Face) about bad UI design and much of the content
relates to dialog boxes. It is a good read for anyone interested in making
user-friendly GUIs. I have read "About Face" but I see that he has a new one
out. I'll have to get a copy of that too.

  
Yeah, that book is sitting on my shelf. I read it years ago. I agree 
that modal dialogs are annoying, but that is the point here. Now people 
will probably just get used to them, as they say, click OK and go on. 
But they can't deny having seen it. I think Cooper's advice against 
dialog boxes regards times when they are unnecessarily interrupt flow. 
In this case, we're trying to interrupt flow.


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


A system modal dialog box?

2006-05-18 Thread Lyle Kopnicky

Hi folks,

I need to create a dialog box in my application that prevents the user 
from doing anything else on the system until OK is clicked. That is, the 
user may not interact with any other windows, of any applications, 
during this time. It would be best if the dialog box was asynchronous, 
so the application could continue to process timer signals while waiting 
for the user to click OK.


I'm using TK in my application, so I looked at the Tk::Dialog method. 
With that, you can make the dialog "local" or "global". I tried 
"global", but it didn't prevent me from interacting with other windows.


Is there a Win32 call that can do this? I read about the MessageBox 
function, which lets you specify SYSTEMMODAL, but it says that doesn't 
stop the user from interacting with other applications, either.


Any ideas? Thanks.

--
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: Performance of Data::Dump

2006-05-05 Thread Lyle Kopnicky

Thomas, Mark - BLS CTR wrote:

Are there modules faster than Data::Dump?



Interesting. I'd never heard of Data::Dump. I always use Data::Dumper.
Have you tried that? It uses XS code so it should be faster.
  
Data::Dump comes with the ActivePerl distribution. From the Data::Dump 
documentation:


The |Data::Dump| module grew out of frustration with Sarathy's 
in-most-cases-excellent |Data::Dumper|. Basic ideas and some code are 
shared with Sarathy's module.


The |Data::Dump| module provides a much simpler interface than 
|Data::Dumper|. No OO interface is available and there are no 
configuration options to worry about (yet :-). The other benefit is 
that the dump produced does not try to set any variables. It only 
returns what is needed to produce a copy of the arguments. This means 
that |dump("foo")| <../../../lib/Pod/perlfunc.html#item_dump> simply 
returns |"foo"|, and |dump(1..5)| 
<../../../lib/Pod/perlfunc.html#item_dump> simply returns |(1, 2, 3, 
4, 5)|.



I tried Data::Dumper, and it ran a bit slower than Data::Dump.

You can also try Storable.
  

I will. Thanks.

--
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: Performance of Data::Dump

2006-05-05 Thread Lyle Kopnicky
Thanks for the suggestions, folks. I'm going to try Storable. I had 
originally skipped it due to lack of readability, but we can easily 
write separate tool to pretty-print the file, even using Data::Dump.


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


Performance of Data::Dump

2006-05-05 Thread Lyle Kopnicky

Hi folks,

I'm using Data::Dump in a project to periodically write a snapshot of a 
hash table to disk, so it can be recovered on failure. Unfortunately, it 
can take 40 seconds to write out a 10,000-entry hash table (each entry 
is itself a small hash table, one entry of which is itself a small hash 
table). By writing it to a string first and then to a file, I found that 
the vast majority of that time is in creating the string, and only 5 
seconds is in writing the file (using print).


If I iterate through the table, writing each entry separately to the 
file, I get a fair improvement. I guess this means that internally, 
Data::Dump is using a lot of inefficient string appends.


Nevertheless, I need to get this operation down to 5 seconds, preferably 
1 second if possible. Are there modules faster than Data::Dump? What 
about MLDBM?


--
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: [perl-win32] Re: Tk beep on Win2K?

2006-05-02 Thread Lyle Kopnicky

Robert May wrote:

#!perl -w
use strict;
use warnings;
use Win32::API();

Win32::API->Import("Kernel32", "Beep", "LL", "L");
Beep(750, 300);
__END__

Yes, that one works! In both RDP and ICA, even with wperl.  It works on 
NT4 and Win2K.  Thank you.


--
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: Tk beep on Win2K?

2006-05-01 Thread Lyle Kopnicky

$Bill Luebkert wrote:

Lyle Kopnicky wrote:

  
No, it's a rackmount server, they tend not to have these things.  But 
now I'm using an ICA session, and if I open a browser, and view flash 
files, I get sound. I get sound when I log into the server. But I don't 
get those beeps.



The normal beep that you get when you do ^G is from the speaker inside
the case of your PC.  With a rackmount, you may be getting a beep, but
not be able to hear it since it's coming from the case in the rack (if
it even has a speaker).

Apparently what you need to do is get the PC or whatever you are logging
in from to generate the beep rather than the MB speaker.
  

I can do that, by typing ^G in the console and hitting Enter.

But I can't do it from a Perl program, running via wperl.

--
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: Tk beep on Win2K?

2006-04-28 Thread Lyle Kopnicky
I just figured something else out. Tk::Widget's bell() works in an RDP 
session on NT4, but not in an ICA session. All the other sound works in 
an ICA session (on both NT4 and Win2K), but not an RDP session. The 
bell() method doesn't work in an RDP or ICA session on Win2K.


--
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: Tk beep on Win2K?

2006-04-28 Thread Lyle Kopnicky

Chris Wagner wrote:

At 06:36 PM 4/27/2006 -0700, Lyle Kopnicky wrote:
  
beeptest.pl.  On the NT4 server, it causes my local PC (remember I'm in 
an RDP session) to emit six PC speaker beeps.  On the Win2K server, it 
runs for the same length of time, but is silent.  There could be some 
other difference besides one server being NT4 and the other Win2K, but I 
don't know what might affect this situation.



Oh ok, this makes a big difference.  U want the remote script to beep you
*through* a remote desktop session right?  I think this has something to do
with the terminal service settings.  I would pour through those and look for
anything about forwarding sound events.
  
OK, I tried it using an ICA session to the Win2K server now, instead of 
an RDP session. That's the typical scenario for our customers. Here's 
the result:


When the session starts, I hear the "Windows startup" music. Then my 
program runs (not in a console window). It opens a web browser, and I 
can go to sites that use sound and hear the sound. But my little timer, 
which is supposed to beep, makes no noise.


I tried Tk::Widget's beep(). No sound. I tried Win32::Sound. Nothing. I 
tried printing a Ctrl+G from within the program. Nothing. I tried 
MessageBeep(DEFAULT). Nothing.


On NT4 though, beep() works.

--
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: Tk beep on Win2K?

2006-04-28 Thread Lyle Kopnicky

$Bill Luebkert wrote:

Lyle Kopnicky wrote:

  

$Bill Luebkert wrote:



Here's an alternative if you can't get it going using API:
 
  
Thanks for the test program.  I have to point out that neither system 
has any audio card installed.  They also don't have many of the default 
sound files installed.  I tried the program you sent me, calling it 
beeptest.pl.  On the NT4 server, it causes my local PC (remember I'm in 
an RDP session) to emit six PC speaker beeps.  



Probably because no sound card.  No built-in sound on M/B either ?
  
No, it's a rackmount server, they tend not to have these things.  But 
now I'm using an ICA session, and if I open a browser, and view flash 
files, I get sound. I get sound when I log into the server. But I don't 
get those beeps.
  On the Win2K server, it 
runs for the same length of time, but is silent.  There could be some 
other difference besides one server being NT4 and the other Win2K, but I 
don't know what might affect this situation.



Can you open a console window and type Ctrl-G in it and see if it beeps
with the normal speaker beep ?
  

Yes, that works.

Can you generate any sound via any method on it ?
  

Yes. See above.

--
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: Tk beep on Win2K?

2006-04-28 Thread Lyle Kopnicky

Timothy Johnson wrote:

Okay, this may be a stupid question, but has the W2k machine EVER
beeped, and are you sure it has no sound drivers installed?  It could
have some kind of sound driver installed and be replacing the PC beep
with sound files and you wouldn't know because you have no output
device.

  
Yes, it beeps if I type Ctrl+G in a console window and hit Enter.  It 
just has codecs installed, no card.


--
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: Tk beep on Win2K?

2006-04-28 Thread Lyle Kopnicky

Excuse me, that's bell(), not beep().

--
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: Tk beep on Win2K?

2006-04-27 Thread Lyle Kopnicky

Chris Wagner wrote:

At 08:26 PM 4/26/2006 -0700, Lyle Kopnicky wrote:
  

But when I run a program calling beep(), I don't hear anything.



U could replace the beep() call with print "\cG";
  
Thanks.  I tried your suggestion.  It seems to work as long as I'm 
running in a console window.  But if I run the program with wperl, it 
does nothing.  Unfortunately, my program has to be run detached from a 
console, via wperl.


--
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: Tk beep on Win2K?

2006-04-27 Thread Lyle Kopnicky

$Bill Luebkert wrote:

Here's an alternative if you can't get it going using API:
  
Thanks for the test program.  I have to point out that neither system 
has any audio card installed.  They also don't have many of the default 
sound files installed.  I tried the program you sent me, calling it 
beeptest.pl.  On the NT4 server, it causes my local PC (remember I'm in 
an RDP session) to emit six PC speaker beeps.  On the Win2K server, it 
runs for the same length of time, but is silent.  There could be some 
other difference besides one server being NT4 and the other Win2K, but I 
don't know what might affect this situation.


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


Tk beep on Win2K?

2006-04-26 Thread Lyle Kopnicky

Hi folks,

I'm having trouble getting the Tk::Widget method beep() to work on 
Win2K.  It works fine on NT4.  I'm using ActivePerl 5.8.4.  If it makes 
any difference, I'm also connecting to the server via an RDP session, 
both cases.


If I open a console window on the Win2K server, through an RDP session, 
and type some Ctrl-Gs, and hit enter, my local PC beeps.  Since those 
beeps are being sent across properly, the terminal server doesn't seem 
to be the problem.


But when I run a program calling beep(), I don't hear anything.

On NT4, beep() works fine.  Any ideas?

--
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: Question about pattern matching

2006-04-20 Thread Lyle Kopnicky

Craig Cardimon wrote:
I'm looking for patterns where the sign "%" or the word "percent" are 
preceded by a group of one or more digits and zero or more spaces.


if( $line =~ /\%|\bpercent\b/i )
{
if( $line =~ /\d+\s*(\%|\bpercent\b/i )
{
 # magic happens
}
}
The outer if is redundant. It will only match more lines, which will 
slow down your program.


Your parentheses are mismatched in the inner if.  Try:

if( $line =~ /\d+\s*(\%|\bpercent\b)/i )
   {
# magic happens
   }

Note that you will not match "43percent", since there is no word 
boundary between "43" and "percent".


--
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: Iffor

2006-04-18 Thread Lyle Kopnicky

Ng, Bill wrote:

Performance isn't really what I'm going for, just simpler code.
If clear code is what you want, you won't get it using a 'next' as some 
have suggested.  A 'next' syntactically looks like any other line, and 
is therefore not easily noticed as part of the control flow.  Unless, 
perhaps, you put a big comment next to it.  Like a 'return' or a 'die', 
it's easily glanced over, and should only be used for exceptional 
circumstances.


I recommend you either:

  1. Embed the 'if' inside the 'for' - this makes it clear what you are
 trying to do.  It is not a significant performance penalty.
  2. Filter out just the items you want to iterate over in advance,
 using 'grep'.

First method:

@a = (1,2,3,4,5);
for (@a) {
   if ($_ != 3) {
   print "something";
   &doSomething();
   print "somethingelse";
   &yada($yada{$ya});
   }
}

Second method:

@a = (1,2,3,4,5);
for (grep { $_ != 3 } @a) {
   print "something";
   &doSomething();
   print "somethingelse";
   &yada($yada{$ya});
}

Personally, I think the second method is the clearest.  You are 
explicitly stating what you are iterating over.  You might even write:


@a = (1,2,3,4,5);
@a_subset = grep { $_ != 3 }; # comment about why I only want these
for (@a_subset) {
   ...
}

Naming intermediate steps is good documentation.

The only reason I'd use the first method is if the condition for the 
'if' could change during the iteration of the loop.  But I try to avoid 
those sorts of situations.


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


Non-blocking IO?

2006-04-17 Thread Lyle Kopnicky

Hi folks,

I'm using the HTTP::Daemon module.  Is there any way to do non-blocking 
IO with that?  Thanks.


--
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: Replace Leading Spaces

2006-04-07 Thread Lyle Kopnicky

Ken Kriesel wrote:

Why not the more concise

$string =~ s/^(\s+)/'0'x(length $1)/e; 
  
Thanks, that is exactly the same as Paul's solution.  Minus the spaces 
around the 'x'.


--
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: Replace Leading Spaces

2006-04-07 Thread Lyle Kopnicky

Dirk Bremer wrote:

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?
  
I think that's kind of confusing.  I like Paul's suggestion.  It's 
short, simple, I look at it and can see what it means right away.  
Here's another way, that should be pretty efficient:


my $string = ' 259.00 ';
(my $trimmed_string = $string) ~= s/^ *//; # remove leading spaces
my $transformed_string = '0' x (length $string - length $trimmed_string) 
. $trimmed_string;


--
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: Want to reduce the speed of execution in Perl script.

2006-04-05 Thread Lyle Kopnicky

Yekhande, Seema (MLITS) wrote:


Does anyone is having different idea about reducing the speed in 
execution? This I am finding out about how to reduce the speed.


You can reduce the speed by: 1) running on a slower machine, 2) running 
other compute-intensive programs at the same time, or 3) inserting a 
bunch of sleep() calls.


I think perhaps you want to /increase /the speed?

--
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: How t set path for repository in PPM?

2006-03-08 Thread Lyle Kopnicky

Yekhande, Seema (MLITS) wrote:


Hello Everyone,

I have installed perl on my PC from ActiveState. But one problem 
exists with it when I give the prompt as ppm.
It goes into the ppm prompt. But when I search Tk or search CGI. It is 
giving me the error as No matches for 'Tk'

Or no matches for CGI.
The repository is set as _http://ppm.ActiveState.com/PPM_ . The 
internet connection exist on my pc.

But not able to install any module using PPM.

You don't have to change the repository location.  You can add new ones, 
e.g.:


   rep add Bribes http://www.bribes.org/perl/ppm

--
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: Deep copy?

2006-03-06 Thread Lyle Kopnicky

Johan Lindström wrote:

At 21:51 2006-03-06, Lyle Kopnicky wrote:

What's the simplest way to make a deep copy of a data structure?
Certainly this must be in some standard module.  I'm trying to back 
up a portion of the registry, using Win32::TieRegistry, to a nested 
hash inside the program.  Later, I'll restore it.


Storable's dclone.

This does not do what I want.  Suppose I have the following:

use Win32::TieRegistry;
my $InternetSettings = $Registry->{'HKEY_CURRENT_USER/Software/Microsoft'
   . '/Windows/CurrentVersion/Internet Settings/'};

Then if I apply dclone to $InternetSettings, it copies the entire 
object.  I just want to copy the registry key as a nested hash.


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


Deep copy?

2006-03-06 Thread Lyle Kopnicky
What's the simplest way to make a deep copy of a data structure?  
Certainly this must be in some standard module.  I'm trying to back up a 
portion of the registry, using Win32::TieRegistry, to a nested hash 
inside the program.  Later, I'll restore it.


--
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: Win32::TaskScheduler: local host?

2006-03-04 Thread Lyle Kopnicky




Chris Wagner wrote:

  At 07:39 PM 3/1/2006 -0800, Lyle Kopnicky wrote:
  
  
According to MSDN, you're supposed to feed SetTargetComputer() a NULL to 
get it to target the local host.  But I don't have any way of passing a 
NULL to the Perl version.  I tried undef, and that generates an error.  
I tried 0, and that fails.

  
  
Just a S.W.A.G. but not knowing what exactly they mean by "NULL" have u
tried an ascii null?  Maybe if u feed it a 0x00 it'll work.
  

Isn't 0x00 the same as 0?  Or is 0 really a C "0" where 0x00 is a C 0?
-- 
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: Win32::TaskScheduler: local host?

2006-03-03 Thread Lyle Kopnicky

Thanks to those who provided suggestions.  They were:

  1. Use ENV{'COMPUTERNAME'} - worked
  2. SetTargetComputer("\0") - gave an error when calling NewWorkItem()
  3. Use Win32::NodeName - worked

I think it would be an improvement to the Win32::TaskScheduler module if 
there was a way to get the behavior you can get in C by passing in a 
NULL.  Nevertheless, I've actually chosen a fourth option - use the host 
name that's already provided in the INI file I've read.


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


Win32::TaskScheduler: local host?

2006-03-01 Thread Lyle Kopnicky

Hi folks,

I'm using Win32::TaskScheduler to schedule tasks, sometimes on the local 
host, sometimes on remote hosts.  My problem is that I can't figure out 
what to set the target computer for, when I want the local host.  That 
is, what parameter do I feed to SetTargetComputer() when I want it to 
target the local host?  Can I do this without knowing the name of the 
local host?


I've found that if I create a new TaskScheduler, then by default it 
operates on the local host.  But if I change it to point at another 
host, then want to point it back at the local host, I don't know how, 
without knowing the name of the local host.  It isn't convenient, the 
way my code is set up, to create a new TaskScheduler every time, 
either.  I've tried '\\', which fails, and the empty string, which 
succeeds for SetTargetComputer(), but fails when I call NewWorkItem().


According to MSDN, you're supposed to feed SetTargetComputer() a NULL to 
get it to target the local host.  But I don't have any way of passing a 
NULL to the Perl version.  I tried undef, and that generates an error.  
I tried 0, and that fails.


Any ideas?

--
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: Fw: How to best replace one string with another in a text file

2006-03-01 Thread Lyle Kopnicky

Chris Wagner wrote:

For these big substitutions on interdeterminate size files I like to roll my
own routines.  U know, go into a read() loop, pull in a buffer, scan with
index() , write out, read, etc.  I'm geared far more toward
performance/coolness than simplicity. ;)
  

Simplicity is the new cool... ;)

--
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: Fw: How to best replace one string with another in a text file

2006-03-01 Thread Lyle Kopnicky




D D Allen wrote:
I think what's going on
is that for
variations 1 and 3, Perl is "slurping" the input file into an
array, performing the substitutions on the array elements, and then
writing
out the array elements.   For variation 2, there's no array involved.
 It's simply "read a line, perform the substitution on that line,
write a line".   And I think the explanation for the time differences
between 1 and 3 is that there is a certain amount of overhead
associated
with the map function -- that's not present with the for loop.
  

Thanks for your informative test.  When we make decisions about how to
code something, it is important to consider what factors are most
important in our situation.  Sometimes, speed will be critical.  At
other times, conceptual clarity of the code, for ease of maintenance,
will be of highest concern.  Most of the time we choose a balance. 
Personally, I find that if speed is not critical (and if it is, you
should be using something faster than current Perl implementations), I
want to emphasize conceptual clarity.

I feel that in the long run, it is best to write clearer code, unless
the performance penalty is overwhelming.  Understand that future
versions of Perl may be optimized to handle some things more
efficiently, e.g. map.  If more people used it, there would be more
incentive for Wall et al to optimize for it.

One issue that arises in designing for clarity in the code is that
different developers are used to different idioms.  So, what is clear
and simple to me may seem obtuse to a future maintainer, and
vice-versa.  Many of the practices in the Best Practices book seem
strange to many Perl developers, but Conway suggests that if we would
all get used to them, we'd be happier in the long run.  It is in that
spirit that I prefer the three-line map solution to the while loop:

my @lines = <$infile>;
map { s/$oldval/$newval/g; $_ } @lines;
print {$outfile} @lines;

It conceptually separates I/O from computations.  It is also more
declarative - saying what you want rather than how to do it.  Some
programmers may find it less familiar than while loops, but I think
that is only because they have been taught to use while loops.  If you
start a new programmer from scratch, my bet is they'll find the map
solution conceptually simpler.  Granted, I have a functional
programming background, so I'm apt to say such things.

Anyway, despite the fact that the map solution is simpler than the
while loop, there is yet a simpler solution to this problem, which I
mentioned earlier.  It involves sucking in the entire file and doing
substitutions on it.  There is no need to impose the conceptual
framework of line-based processing.  It might even be faster.  I'm
eager to find out.

Here is the variant I suggest you test:

use File::Slurp;
...
my $text = read_file($input_file, binmode => ':raw');
$text =~ s/$oldval/$newval/g;
print {$outfile} $text;

(I know Conway suggests using Perl6::Slurp, but I couldn't find a PPM
for it, so I used File::Slurp.  Admittedly, the binmode => ':raw' is
a bit obtuse, and could be left out.  I do think it will boost
performance slightly, which I am curious about in the context of this
discussion.)
-- 
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


PPM object interface?

2006-02-28 Thread Lyle Kopnicky

Hi folks,

I know how to use PPM from the command line, but I want to call it from 
Perl, preferably without spawning separate processes.  There seems to be 
a PPM3 module installed in ActivePerl, but how do I access it?  E.g., I 
would like to write something like:


   use PPM;
   my $ppm = new PPM;
   $ppm->install('http://blahblah.net/Package.ppd') or die "Failed to 
install package.";

   my @search_packages = $ppm->search('FunPackage');
   print (map "$_->name\n", @search_packages);

--
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: How to best replace one string with another in a text file

2006-02-28 Thread Lyle Kopnicky
Another option which occurred to me - there's no reason to replace text 
line-by-line here.  You could write:


$text = ;
$text ~- s/$oldnodename/$curnodename/g;
print OUTFILE $text;

Although I agree with Alejandro... if your file is gigabyte-sized, you 
will probably want to go back to the while loop.  But that' s more of a 
limitation of the operating system than of your program.  I mean, it's 
supposed to be caching reads and writes, no?


--
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: How to best replace one string with another in a text file

2006-02-28 Thread Lyle Kopnicky

Paul,

Here's an even more frighteningly succinct version of your loop, without 
the intermediate variable:


print OUTFILE map { s/$oldnodename/$currnodename/g; $_ } ;

--
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: How to best replace one string with another in a text file

2006-02-28 Thread Lyle Kopnicky

Paul Rousseau wrote:

Hello,

 I want to open a text file, look for a specific string, replace it 
with a new string, and write the line out to another file. For lines 
not containing the specific string, I want to write out as is.


I was wondering if it is possible to do it with a map or splice or 
grep command rather than a foreach loop.


Well, you didn't use a foreach loop in your sample below, you used a 
while loop.  But yes, it is possible to do it with a map, not a grep or 
a splice.


Don't confuse the Perl grep with the Unix command.  The perl grep works 
on a single string, while the Unix grep repeats the same match over 
multiple lines.  Also, grep only finds strings; it doesn't do any 
replacements.


A splice is for inserting or removing list elements - not what you want 
to do.
Perhaps, I should be looking at some executable that replaces one 
string with another within a file?


I have resorted to a foreach loop.
Nope, you used a while loop.  You could have just as easily used a 
foreach, though.  Frankly, I think it's a perfectly appropriate 
application of a while loop.  I wouldn't say you 'resorted' to it.

Here is a snippet of my code:

  $currnodename = "AMACHINE";
  $oldnodename = "BMACHINE";
  $infile = "$ENV{FT}\\qld\\$msg.qli";
  $outfile = $ENV{TEMP} . "\\$task.tmp";

  open (INFILE, "<$infile") || die "Can not open $infile";
  open (OUTFILE, "+>$outfile") || die "Unable to open $outfile";
  while ($inline = )
 {
  chomp $inline;
The chomp should not be there.  You still want the newline in the output 
string, right?

  $inline =~ s/$oldnodename/$currnodename/g;
  print OUTFILE $inline;
 }
  close INFILE;
  close OUTFILE;


Here's your loop rewritten using map:

@lines = ;
map { s/$oldnodename/$currnodename/g; $_ } @lines;
print OUTFILE @lines;

If for some reason you wanted to be able to reuse the original lines, so 
you could do a different substitution on them in another pass, you could 
preserve them thusly:


@inlines = ;
map { s/$oldnodename/$currnodename/g; $_ } (@outlines = @inlines);
print OUTFILE @outlines;

Finally, here's your loop, actually written as a foreach:

@lines = ;
foreach $line (@lines)
{
   $line =~ s/$oldnodename/$currnodename/g;
}
print OUTFILE @lines;

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


Calling .NET from Perl

2006-02-09 Thread Lyle Kopnicky

Does anyone know of a way to call .NET assemblies from a Perl script?

--
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: Perl bug?

2006-02-08 Thread Lyle Kopnicky

Glenn Linderman wrote:
On approximately 2/8/2006 1:06 PM, came the following characters from 
the keyboard of Lyle Kopnicky:
Thanks for the explanation.  As far as I am concerned, then, perl's 
closure model is unintuitive and broken.  It doesn't work like 
closures in any other language I have seen, including Pascal, 
Smalltalk, Common Lisp, Scheme, ML, or Haskell.  Don't know about 
Python or Ruby, but I suspect they don't make this mistake.  It 
should always create a new closure for gettoken() each time parse() 
is run.  The workaround, as mentioned, is to write $gettoken = new 
sub {...}, instead, but that workaround shouldn't be required.  
Hopefully this will be fixed in Perl 6.


Well, I'm not really all that familiar with closures in other 
languages; if Pascal had them back in the late 70s when I used it, I 
never happened across them I haven't used the other languages you 
mention enough to comment.



Yes, I believe it did.
However, given that Perl allows two techniques for closures.. the 
"anonymous sub closure" (which seems to be what you expect), and the 
"named sub" closure (which was used in this example), with different 
behaviours, doesn't that give it more flexibility than the other 
languages you mention?  In Perl, you can have two different types of 
scoping for closures--can you in those other languages?


OK, to be fair, most of the languages I mentioned only allow the 
"anonymous sub" type closure, although you can assign it to a variable, 
as in Perl.  Pascal definitely supports the "named sub" type, and 
handles just like other languages handle the "anonymous function" type.  
Incidentally, C# also handles "anonymous methods" the same way, as 
proper closures, as does Java with its "anonymous inner classes".  Dunno 
how Java treats named inner classes.  Can you define one inside a 
method?  Anyone?


It seems like it would be nice that you can do to different things in 
Perl.  But that would be true only if there was an advantage for the 
distinct behavior of each, under different circumstances.  I see no 
advantage to the way Perl treats nested named subroutines.  As far as 
I'm concerned, it is counterintuitive, as evidenced by John's problem.


Would you think it was advantageous, say, if addition and subtraction 
worked differently inside subs than they did in the main script?  I 
personally think consistency is better.


I guess the Perl philosophy is to add on a hodgepodge of conflicting 
features, and figure the programmer can probably sort it all out.  
Although in Perl 6 that sort of concept seems to be going by the wayside.


--
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: Perl bug?

2006-02-08 Thread Lyle Kopnicky

Glenn Linderman wrote:
So, $lTokens is a reference from a sub, to a variable declared outside 
of the sub (specifically, to the $lTokens declared in parse on its 
first invocation), thus making gettoken a closure and causing that 
instance of $lTokens to be preserved as part of the state of the closure.


Thanks for the explanation.  As far as I am concerned, then, perl's 
closure model is unintuitive and broken.  It doesn't work like closures 
in any other language I have seen, including Pascal, Smalltalk, Common 
Lisp, Scheme, ML, or Haskell.  Don't know about Python or Ruby, but I 
suspect they don't make this mistake.  It should always create a new 
closure for gettoken() each time parse() is run.  The workaround, as 
mentioned, is to write $gettoken = new sub {...}, instead, but that 
workaround shouldn't be required.  Hopefully this will be fixed in Perl 6.


--
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: Telnet on XP

2006-01-13 Thread Lyle Kopnicky

Jerry Kassebaum wrote:


Friends,

I know how to change permissions on my website with telnet on my 
Windows ME machine. I connect by typing web7.seanic.net in the 
Hostname box, telnet in the Port box, and vt100 in the TermType box.


However, I can't figure out what to do on my Windows XP machine. I 
type "open web7.seanic.net" to no avail.


Open the command prompt.  Type "telnet web7.seanic.net".

I highly recommend PuTTY 
(http://www.chiark.greenend.org.uk/~sgtatham/putty/) instead.


--
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: Classes as modules?

2006-01-12 Thread Lyle Kopnicky

Dirk Bremer wrote:


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.
 

Thank you, that will work!  You have just given me reason to get rid of 
my ugly code.


The only slight tweak I have is that my start script is one level down 
from the root dir.  But that's easy enough to handle.  Looks like 
FindBin does the heavy lifting.


My folders are arranged thusly:

somerootpath/
   client/
   common/
   server/

The starting script is either in 'client' (for the client software) or 
'server' (for the server software).  They would need to include 
scripts/modules in their own directory, or possibly subdirectories, plus 
the ones in 'common'.


So, I guess I could write, in the server code:

use FindBin qw($ServerDir);
use lib $ServerDir;
use lib "$ServerDir/../common";

--
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: Classes as modules?

2006-01-12 Thread Lyle Kopnicky

Chris Wagner wrote:


At 01:44 PM 1/12/2006 -0800, Lyle Kopnicky wrote:
 

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.
   



The current directory is automatically in @INC.  If the script and module
are in the same dir then u have to do nothing.

Wrong.  The script is not necessarily in the current directory.  Let's 
say you type at the prompt:


 C:\> \devel\perl\project2\main.pl

Then the current directory is 'C:\', but the script is in 
'C:\devel\perl\project2\main.pl'.  If your modules are all in 
'C:\devel\perl\project2\', then you want that path in @INC.  But I can't 
use the literal path, it must be computed, lest I move the project to 
'C:\test\project2' or something like that.



 If the the path is always
something known reletive to the current dir u can try use lib "../dir"; or
first find the current dir with use Cwd; and then chopping off the last dir
component and putting the result into @INC.
 

That's the kind of stuff done by the code I attached.  Except it first 
has to figure out what the script's dir is.  What we do know is that $0 
is the path to the script, relative to the current dir.  Hence the call 
to File::Spec->rel2abs().


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 
   



. is always in @INC.
 

But, as I said, '.' is not necessarily where the script is.  That's why 
in my script, I computed where the script is, went up one directory, and 
did a chdir.


--
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: Classes as modules?

2006-01-12 Thread Lyle Kopnicky

Chris Wagner wrote:


At 11:13 AM 1/12/2006 -0800, Lyle Kopnicky wrote:
 


  * use() requires that you use a bareword for the module name (might
be nice, if I could solve the @INC path problem)
   



I don't know why u think u have a @INC problem.  There's lots of ways to do
it.  use lib "path", push @INC, path, perl -Ipath.  U can even put an
anonymous routine directly in @INC that will be evaluated to come up with
the approriate path.
 


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,$ServerPath,''));


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: Classes as modules?

2006-01-12 Thread Lyle Kopnicky

Foo Ji-Haw wrote:

I don't think it's more difficult to call a require(), use() helps in 
the bigger scheme of things, like determining the scope of your 
variables and methods, and making sure you package similar functions 
together. use() also makes sure at compile time that the libraries are 
available, whereas require() only checks at runtime.


There's more to the difference between the two, and you may want to 
read up the documentation for the details. 


According to the documentation, use Module is just:

   BEGIN { require Module; import Module; }

So, the only differences between the two are:

   * use() always happens at compile time (which seems to cause more
 trouble than it solves)
   * use() calls the import function in the module (which would
 probably be empty, for a class module)
   * use() requires that you use a bareword for the module name (might
 be nice, if I could solve the @INC path problem)

--
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: Classes as modules?

2006-01-12 Thread Lyle Kopnicky

Foo Ji-Haw wrote:





Well, the two files in question are not huge.  They each have one 
class.  What's the difference between require-ing them later, and 
use-ing them later?  Why is it more difficult to require them?



I don't think it's more difficult to call a require(), use() helps in 
the bigger scheme of things, like determining the scope of your 
variables and methods,


Well, each of these two files has exactly one package, which is a 
class.  So, doesn't the package already determine the scope?



and making sure you package similar functions together.


I can't do any better than putting one class in a file.

use() also makes sure at compile time that the libraries are 
available, whereas require() only checks at runtime.


That gets tricky.  Because I don't know how, at compile time, to tell 
use() where the libraries are.  I've looked through the perlmod 
documentation, and it doesn't seem to address this issue.  I looked in 
the Camel Book, and it talks about 'use lib'.  But what's the default?


What I need to do is put in the search path the parent directory of the 
one containing the main script being executed.  Right now I have about a 
dozen lines of code to figure that out when the script starts, which 
itself uses the File::Spec module.  I guess I can put all that code in a 
BEGIN block, so it can run at compile time.


But in Perl, files are compiled just before they are run.  It's not like 
C, where there is a separate compilation step.  So again, I don't see 
the advantage to checking for the location of the module at compile time.


There's more to the difference between the two, and you may want to 
read up the documentation for the details. It seems that best 
practices go strongly with use(), and a lot of add-on support are 
based on that style of development.





I will say that this is not a Perl-thing, but rather a good general 
software development mindset.




Thanks, but this does seem like a Perl-thing.  No other language 
distinguishes between 'package-in-a-file' and 'module'.



I would say ASP, but ASP does not have a concept of a module...

In my previous email, I was assuming that you simply split all the 
functions in into 2 files without using packages, and merging them 
with a require(). If you are already using packages, then go for use().


In most of my scripts, I am not currently defining packages.  Just in 
the two that represent classes.  I may convert them all to packages, if 
I can be convinced this is useful.  But if I put every function in a 
file into a package, only to export it again, so it can be imported in 
other files, what's the difference?


--
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: Classes as modules?

2006-01-11 Thread Lyle Kopnicky

Foo Ji-Haw wrote:



OK, looking at 'perlnewmod', it has a section called 'What should I 
make into a module?', which states:


"You should make a module out of any code that you think is going to 
be useful to others."


That settles my question.  The classes I have written for this 
project are specific to this project, thus not useful to others.  
Thus, I will keep them in .pl files, not try to make modules out of 
them.



If this is not your first and last time you're using Perl, then it is 
a good practice to create modules to group similar functionalities 
together. Creating a huge .pl file, or lots of .pl files  (and 
require() them later) only makes future debugging and expansion difficult.


Well, the two files in question are not huge.  They each have one 
class.  What's the difference between require-ing them later, and 
use-ing them later?  Why is it more difficult to require them?


Creating a module is painless, yet it sets you on the right path for 
any complexities that may arise.


I will say that this is not a Perl-thing, but rather a good general 
software development mindset.


Thanks, but this does seem like a Perl-thing.  No other language 
distinguishes between 'package-in-a-file' and 'module'.


In Java, classes are required to be in their own file, and every file is 
'.java'.  Or '.jar', which contains a bunch of related classes.


The .NET equivalent of a perl package is a namespace.  They also have 
source files, classes, 'modules' and 'assemblies'.  A source file can 
contain multiple namespaces.  A class can be spread across source 
files.  A module can contain multiple namespaces, and I think a 
namespace can be spread across modules.  But a class must be contained 
in a single module.  An assembly can contain multiple modules (but most 
have only one).  A module is sort of like a Java '.jar' file.  I'm not 
saying it's better or worse, just different.  Every language/framework 
is different.


--
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: Classes as modules?

2006-01-11 Thread Lyle Kopnicky

DZ-Jay wrote:



On Jan 7, 2006, at 03:49, Lyle Kopnicky wrote:

Doesn't that just let me import the methods of the class into my own 
namespace, from another file?  That would be weird - they're supposed 
to be methods of a class.  They belong in the class' namespace, not 
mine.



They won't be imported unless you explicitly allow it (by using 
Exporter, etc).  What you are calling a "module" is merely a package 
in its own file.  When using Perl classes, a 'module' and a 'package' 
are pretty much interchangeble.


Well, that's what I have right now.  Two packages, each in their own 
file.  Each one is a class.  But they are '.pl' files.  Is there any 
reason to make them '.pm' files?  I don't see why I would want to export 
anything from them.


  You should read up on how Perl uses modules, packages and classes in 
the perldoc.


I have read that, thanks.  It seems like more trouble than it's worth to 
make it them modules.  For example, right now I have the class 
TicketQueue in 'server/V-Res-TicketQueue.pl' and TicketSubQueue in 
'server/V-Res-TicketSubQueue.pl'.  In 'server/V-Res.pl', I have the line:


   require 'server/V-Res-TicketQueue.pl';

The 'server/' path is necessary, since it's relative to the current 
directory, not the location of 'V-Res.pl'.  Then, within 
'V-Res-TicketQueue.pl', I have:


   require 'server/V-Res-TicketSubQueue.pl';

So, how would I make these into modules?  Suppose I just rename them 
with '.pm' extensions.  Then, In 'server/V-Res.pl', I could write:


   require 'server/V-Res-TicketQueue.pm';

And what would that buy me?  Could I write:

   use server::V-Res-TicketQueue;

?  I don't think so.  It woudn't like the dashes in the name, or the 
lowercase name for 'server', and it wouldn't match the package name, 
which is just TicketQueue.


I could add the 'server' folder to @INC.  Then I still couldn't write:

   user V-Res-TicketQueue;

because it wouldn't like the dashes.  Perhaps I could rename the file to 
just 'TicketQueue.pm'.  Or I could make a VRes folder, then put 
'TicketQueue.pm' inside of it?  Then I'd have to change the package name 
to VRes::TicketQueue.


Why go through all these hijinks?  I still don't see what I'm getting 
out of this.  Why not just leave things the way they are?


For library modules, that have top-level utility subroutines, I can 
understand making it a module.  But for a class, it doesn't seem to make 
sense.  There's no need to export anything, since you can access methods 
through the objects.  Just a package-in-a-file seems to work just fine.


FYI, I'm only using the TicketQueue class from 'V-Res.pl', and only 
using TicketSubQueue from 'V-Res-TicketQueue.pl'.  So reuse isn't really 
an issue.


Thanks.

--
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: Classes as modules?

2006-01-10 Thread Lyle Kopnicky




$Bill Luebkert wrote:

  Lyle Kopnicky wrote:

  
  
Thanks for your reply.  But supposing I'm going to keep each class in 
it's own file, what is the advantage of making that file a module?  

  
  
Have you read the man pages on modules ?

perlmod Perl modules: how they work
perlmodlib  Perl modules: how to write and use
perlmodstylePerl modules: how to write modules with style
perlmodinstall  Perl modules: how to install from CPAN
perlnewmod  Perl modules: preparing a new module for distribution
  

OK, looking at 'perlnewmod', it has a section called 'What should I
make into a module?', which states:

"You should make a module out of any code that you think is going to be
useful to others."

That settles my question.  The classes I have written for this project
are specific to this project, thus not useful to others.  Thus, I will
keep them in .pl files, not try to make modules out of them.
-- 
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: Classes as modules?

2006-01-07 Thread Lyle Kopnicky

$Bill Luebkert wrote:


Lyle Kopnicky wrote:
 


Hi folks,

This is just a straight-up Perl question:  Is there any advantage to 
turning a class into a module?  Or does it make more sense to put 
multiple classes in one file?  Thanks.
   



It's easier to keep track of them if they have their own modules.
You can obviously put sub-classes together in one module if it's
convenient, but I can't see why you'd want to combine unrelated
classes/packages in a module.
 

Thanks for your reply.  But supposing I'm going to keep each class in 
it's own file, what is the advantage of making that file a module?  
Doesn't that just let me import the methods of the class into my own 
namespace, from another file?  That would be weird - they're supposed to 
be methods of a class.  They belong in the class' namespace, not mine.


Thanks,
Lyle Kopnicky

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


Classes as modules?

2006-01-06 Thread Lyle Kopnicky

Hi folks,

This is just a straight-up Perl question:  Is there any advantage to 
turning a class into a module?  Or does it make more sense to put 
multiple classes in one file?  Thanks.


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


SQL problem

2005-11-23 Thread Lyle Kopnicky

Hi folks,

Perhaps I should send this question to a SQL Server forum, but someone 
here might be able to spot the problem.


I am accessing SQL Server through Perl and DBI.  I have written a number 
of queries.  I prepare all the queries once at the start of the program, 
and then execute them as needed.


I do not get an error when preparing any of the queries.  However, when 
I attempt to execute this query, called $MinsUsedInRangeQuery1, I get 
the error


DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver][SQL 
Server]Line 1: Incorrect syntax near ','. (SQL-42000)
[Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be 
prepared. (SQL-42000)(DBD: st_execute/SQLExecute err=-1) at 
server/V-ASC-UsageDB.pl line 333.


How strange:  It said the statement could not be prepared.  But 
supposedly it was already prepared!  As for the syntax error, does 
anybody have an idea what is wrong in the SQL syntax?  Here's the code:


### when program starts

$MinsUsedInRangeQuery1
   = $DBH->prepare('DECLARE @StartRange datetime, @EndRange datetime'
   . ' SET @StartRange = ?, @EndRange = ?'
   . ' SELECT SUM(DATEDIFF(mi,StartTime,EndTime))'
   . ' AS MinsUsed FROM Sessions'
   . ' WHERE AuthSource = ? AND UserID = ?'
   . ' AND StartTime BETWEEN @StartRange AND @EndRange'
   . ' AND EndTime BETWEEN @StartRange AND @EndRange')
   || die 'Unable to prepare MinsUsedInRange query 1';

### later on...

LogText(1, "Executing MinsUsedInRange1 query with parameters "
   . "($StartRange, $EndRange, patron, $UserID)");
if (!$MinsUsedInRangeQuery1->execute($StartRange, $EndRange,
   'patron', $UserID)) {
   $MinsUsedInRangeQuery1->finish;
   die("Unable to execute MinsUsedInRange query 1:"
   . " $DBI::errstr");
}
$Row = $MinsUsedInRangeQuery1->fetchrow_hashref;
if (!$Row) {
   $MinsUsedInRangeQuery1->finish;
   die "No row returned from MinsUsedInRange query 1";
}
$MinsUsedInRange += $Row->{'MinsUsed'};
$MinsUsedInRangeQuery1->finish;

### end code segment

If you can suggest another forum I should use, please do.  Thanks!

--
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: Directory Test -d

2005-08-23 Thread Lyle Kopnicky

Adam Peterson wrote:


hi,

i'm attempting to open a parent directory that contains many sub
directories and a few text and .pdf files. i want to test to see if the
current file/dir is a directory before attempting to open it and test the
filenames within it. i'm trying to use -d test but it doesn't seem to work
and says that everything is not a dir when it is! i am accessing a network
share.
 

You have to use the full pathname of the dir you are checking with -d, 
unless it is in the current directory.


Thus, instead of (-d $dir), you need to write (-d "$dirpath\\$dir").

--
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: Looking for combination.pm

2005-08-02 Thread Lyle Kopnicky
Simon YEE wrote:

> Some time ago, I downloaded a perl pkg called combination.pm
> It's used to create combination from lists. However, after
> re-installing my hard disk
> after a crash, I can't find the file anymore.
>
> Could someone advise where I can download this pkg again?

I saw a module on CPAN called Math::Combinatorics. That might help.

There seem to be a lot more modules for generating permutations.

-- 
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: Unexpected SIGQUIT

2005-07-13 Thread Lyle Kopnicky

Lyle Kopnicky wrote:


Hi folks,

I've written my program to trap a SIGQUIT and gracefully exit, because 
that's what it gets if it's being run in a command prompt and I close 
it.  It will do the same for a SIGINT (Ctrl+C).


Sorry, I meant to say gets a SIGQUIT on user logout or system shutdown.  
It gets a SIGHUP when I close the command prompt.




It runs as an HTTP server, so it's supposed to stay up continuously.  
I am launching it through an 'at' command in the morning (the server 
reboots each night).


For some reason, on some occasions, the program is receiving a SIGQUIT 
and shutting down.  I know this because it logs that fact.  This 
happened, for example, last Wednesday and today.


Why would a System process started by the scheduler receive a 
SIGQUIT?  I don't believe anyone's going in there trying to kill it.


I could solve this problem by making it ignore SIGQUIT, but I wanted 
it to behave gracefully when I close a command prompt from which I am 
running it.  I would rather find out why it is receiving this signal.


I mean, when the system shuts down.  But, it doesn't always seem to get 
that SIGQUIT when the system shuts down, either.  :(



Any ideas?


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


Unexpected SIGQUIT

2005-07-12 Thread Lyle Kopnicky

Hi folks,

I've written my program to trap a SIGQUIT and gracefully exit, because 
that's what it gets if it's being run in a command prompt and I close 
it.  It will do the same for a SIGINT (Ctrl+C).


It runs as an HTTP server, so it's supposed to stay up continuously.  I 
am launching it through an 'at' command in the morning (the server 
reboots each night).


For some reason, on some occasions, the program is receiving a SIGQUIT 
and shutting down.  I know this because it logs that fact.  This 
happened, for example, last Wednesday and today.


Why would a System process started by the scheduler receive a SIGQUIT?  
I don't believe anyone's going in there trying to kill it.


I could solve this problem by making it ignore SIGQUIT, but I wanted it 
to behave gracefully when I close a command prompt from which I am 
running it.  I would rather find out why it is receiving this signal.


Any ideas?

--
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: ppm.ActiveState.com offline?

2005-07-12 Thread Lyle Kopnicky

Chris wrote:

I assume the ppm server is offline? 



ppm> install xml-rss
Error: No valid repositories:
Error: 500 Can't connect to ppm.ActiveState.com:80 (connect: Unknown error)
Error: 500 Can't connect to ppm.ActiveState.com:80 (connect: Unknown error)
ppm>
 

Yes, I have been having this problem since yesterday evening.  Does 
anyone know if there are any mirrors?  Or else, how can I install this 
stuff from the CPAN .tar.gz package?


--
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: Test if string is a number?

2005-06-29 Thread Lyle Kopnicky
Thanks folks.  I think I'll go with looks_like_number from 
Scalar::Util.  I like to use library routines where possible.  I don't 
know how I overlooked that, since I poked through Scalar::Util earlier.


It just seems bizarre to me that something like that isn't a builtin.  I 
mean, you can't even tell strings from numbers?  I'm used to working in 
strongly typed languages.


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


Test if a string is a number?

2005-06-29 Thread Lyle Kopnicky

Hi folks,

I have a seemingly simple problem, but I can't find a satisfying 
solution.  I have a function which tests to see if a value represents 
what I want to call "true".  Here's a simplified version:


   if ($val =~ /true/i || $val =~ /t/i || $val != 0) { return 1; } else 
{ return 0; }


The text might be numeric or not.  If it is numeric, I want to accept 
anything but zero as true.  But, if I run this on a textual non-true 
value, such as "false", I get:


 Argument "false" isn't numeric in numeric ne (!=) at ...

The code works, but I don't want to get the warning (I'm using 
'warnings').  So, how can I test to see if it's a numeric value, before 
I try to use it as one?  I tried using int() to convert it, but that 
gives the same warning.


Any ideas?  Thanks.

--
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: User properties?

2005-06-08 Thread Lyle Kopnicky

Solli Moreira Honorio wrote:


> Hi folks,
>
> I need to read/write some properties of user accounts, specifically:
>
> * profile name
> * initial program command line
> * initial program working directory
>
> I have found that I can get/set the profile name using the 
Win32API::Net

> module. But, I can't figure out how to get/set the initial program info
> (this is NOT the same as the logon script). There must be some way to
> do it! Does anyone know how?


Have you tried Win32::Lanman ? You can use 
Win32::Lanman::NetUserSetInfoNetUserSetInfo to set user properties easy.


Thanks, it looks like Win32::Lanman::WTSQueryUserConfig and 
WTSSetUserConfig are what I need.  If only I can figure out what 
parameters to send them


- Lyle Kopnicky

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


User properties?

2005-06-06 Thread Lyle Kopnicky

Hi folks,

I need to read/write some properties of user accounts, specifically:

   * profile name
   * initial program command line
   * initial program working directory

I have found that I can get/set the profile name using the Win32API::Net 
module.  But, I can't figure out how to get/set the initial program info 
(this is NOT the same as the logon script).  There must be some way to 
do it!  Does anyone know how?


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


Re: Can't unload hive

2005-04-29 Thread Lyle Kopnicky
I talked to the author of Win32::TieRegistry, Tye (!) McQueen.  The 
problem is that the module is trying to unload the hive when the object 
is destroyed, at the end of the file, but it has already been unloaded.  
The solution is, instead of writing

   $ProfileHive->UnLoad;
is to write
   undef $ProfileHive;
He is going to fix the bug and update the documentation.  (Yes I know 
I'm top posting but I think it makes sense in this case.)

- Lyle
Lyle Kopnicky wrote:
Hi,
I am now having trouble unloading a hive.  I can load it, and read a 
value just fine - but when it gets to the UnLoad statement, I get the 
error "Couldn't unload /Users/./: The parameter is incorrect."

The hive seems to unload by itself when the program quits - but why 
can I not unload it manually?

Thanks,
Lyle

use Win32::TieRegistry (Delimiter=>'/');
my $ok = $Registry->AllowLoad(1);
my $ProfileHive = $Registry->{"Users"}->Load($TestProfile, ".");
#$ProfileHive->{"KeyName//$ValueName"} = $NewValue;
my $CurValue = $ProfileHive->{"$KeyName//$ValueName"};
print "value = $CurValue\n";
unless ($ProfileHive->UnLoad) {
   print "Error - unable to unload hive.\n";
}
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Can't unload hive

2005-04-27 Thread Lyle Kopnicky
Hi,
I am now having trouble unloading a hive.  I can load it, and read a 
value just fine - but when it gets to the UnLoad statement, I get the 
error "Couldn't unload /Users/./: The parameter is incorrect."

The hive seems to unload by itself when the program quits - but why can 
I not unload it manually?

Thanks,
Lyle

use Win32::TieRegistry (Delimiter=>'/');
my $ok = $Registry->AllowLoad(1);
my $ProfileHive = $Registry->{"Users"}->Load($TestProfile, ".");
#$ProfileHive->{"KeyName//$ValueName"} = $NewValue;
my $CurValue = $ProfileHive->{"$KeyName//$ValueName"};
print "value = $CurValue\n";
unless ($ProfileHive->UnLoad) {
   print "Error - unable to unload hive.\n";
}
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Can't read from registry

2005-04-25 Thread Lyle Kopnicky
Hi folks,
I'm trying to use Win32::TieRegistry to read and set values in the 
registry.  It's not working.  I made this short example program which 
demonstrates the problem.  When I run it, I get "value =" (no value).  I 
have checked that the corresponding registry key/value exists using 
RegEdit.  This is on ActivePerl 5.8.6 build 811 on Windows XP Pro.

Thanks,
Lyle Kopnicky
--
use Win32::TieRegistry;
$Registry = Win32::TieRegistry->new("LMachine", {Access=>KEY_ALL_ACCESS,
Delimiter=>'/'});
$CurValue = $Registry->{"Software/Microsoft/Windows/CurrentVersion/"
   . "Explorer/Tips//18"};
print "value = $CurValue\n";
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: app to create directories with a browser...

2005-04-13 Thread Lyle Kopnicky
bruce wrote:
hi...
i'm trying to find an app to allow me to somehoe specify a dir/folder
structure and to be able to create the dir on the hard drive, using the
browser...
 

Please be more specific.  It sounds as if Windows Explorer will fit the 
bill.  It's GUI, too.

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


Repeated message

2005-04-12 Thread Lyle Kopnicky
Am I the only one who received the following message eight times 
yesterday?  Is something wrong with the listserv or is it on my side?

- Lyle Kopnicky
Charles K. Clarkson wrote:
andrew Black <> wrote:
: $	myprog.pl   *.html
: 
: and the program is basically
:  while ( <> )
: 	{  do something	}
: 
: Is there a way of achieving the same on Win32, hopefully in
: a way that would still allow my script to run under Unix?

   This works on my win XP box with 5.8.6. According to the
docs, Win32::Autoglob has no effect on foreign systems.
use strict;
use warnings;
use Data::Dumper 'Dumper';
use Win32::Autoglob;
print Dumper [EMAIL PROTECTED];
__END__
HTH,
Charles K. Clarkson
 

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


Re: detect name of username and password of user

2005-04-06 Thread Lyle Kopnicky
Ted Yu wrote:
Is there a way for Perl to read the username and password of the XP 
windows user?  I want to be able to set schedules using dos command 
"schtasks" without the user having to enter their name and password, 
and just have the system enter it automatically.
I'm not sure about on Windows (I think it's the same), but on Unix 
variants, the system doesn't store the user's password - only a hash of 
it.  The system doesn't *know* the password.  So the only way to figure 
out the user's password is by trying to crack it.

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


Re: [OT] Spam to list

2005-04-04 Thread Lyle Kopnicky
Chris Wagner wrote:
Ah Fido-net!  Yeah those were the days when "netiquette" evolved.  Because
back then we were all on dial up connections, slow ones, and it mattered if
u cut out irrelevant text or not.  Now people take bandwidth and drive space
for granted.  These damn whipper snappers... ;)
 

Yeah, I used to use Fidonet, too.  But I still think that even if we 
don't care about the bandwidth today, we should still care about the 
time it takes people to read something.

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


Re: Spam to list [OT]

2005-04-04 Thread Lyle Kopnicky
Chris Wagner wrote:
At 12:25 PM 4/4/05 -0700, jeff griffiths wrote:
 

I like the idea of pre-pending a tag to the subject though, and we do
this a lot with other lists ( Komodo-discuss being the one that comes to
mind ). Are there any strong objections to this?
   


I think that's a bad idea.  I've been on other lists like that and the
effect is that less of the actual subject is visible in the inbox because
it's displaced by the tag.  I've only got 44 chars as it is.
 

Although I'm not advocating the subject-tag, I will point out that it 
could be put at the *end* of the subject line.

Of course, it's better just to filter on the Cc field, or the List Id field.
- Lyle
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: [OT] Spam to list

2005-04-01 Thread Lyle Kopnicky
I'm all for putting the sender's address in the From header and the list 
address in the Reply-To header.  That's how it works on most every list 
I'm on, and it works great.

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


How to find process owner?

2005-03-31 Thread Lyle Kopnicky
I am now using the code below to print a list of processes on the 
computer.  It works.  However, I would like to be able to tell which 
user is running each process.  I need to be able to find a process with 
a certain name, running under a certain user account.  How can I do this?

Thanks,
Lyle Kopnicky
##
use Win32::PerfLib;
%proc_list = get_remote_process_list('');
foreach $i (keys %proc_list) {
   print "$i: $proc_list{$i}\n";
}
sub get_remote_process_list {
my $server = $_[0];
my %rtasks;
my %counter;
Win32::PerfLib::GetCounterNames($server, \%counter);
my %r_counter = map { $counter{$_} => $_ } keys %counter;
# retrieve the id for process object
my $process_obj = $r_counter{Process};
# retrieve the id for the process ID counter
my $process_id = $r_counter{'ID Process'};
# create connection to $server
my $perflib = new Win32::PerfLib($server);
my $proc_ref = {};
# get the performance data for the process object
$perflib->GetObjectList($process_obj, $proc_ref);
$perflib->Close();
my $instance_ref = $proc_ref->{Objects}->{$process_obj}->{Instances};
foreach my $p (sort keys %{$instance_ref})
{
   my $counter_ref = $instance_ref->{$p}->{Counters};
   foreach my $i (keys %{$counter_ref})
   {
   if($counter_ref->{$i}->{CounterNameTitleIndex} == $process_id)
   {
   $rtasks{$counter_ref->{$i}->{Counter}} =
   $instance_ref->{$p}->{Name};
   }
   }
}
 return %rtasks;
}
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Nothing from Win32::PerfLib::GetCounterNames()

2005-03-31 Thread Lyle Kopnicky
Rhesa Rozendaal wrote:
Lyle Kopnicky wrote:
I tried the following code:
 use Win32::PerfLib;
 my %counter;
 Win32::PerfLib::GetCounterNames('localhost', \%counter);

Try an empty string for the local machine:
Win32::PerfLib::GetCounterNames('', \%counter);
That worked.
Thanks,
Lyle Kopnicky
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Nothing from Win32::PerfLib::GetCounterNames()

2005-03-31 Thread Lyle Kopnicky
I tried the following code:
 use Win32::PerfLib;
 my %counter;
 Win32::PerfLib::GetCounterNames('localhost', \%counter);
 print "Number of counter hash keys: " . (scalar (keys counter)) . "\n";
... and I get 0.  I am running it on Windows XP Home with ActiveState 
Perl 5.8.6.  I also tried it on Windows NT 4.0 TSE with ActiveState Perl 
5.8.3.  Same answer.

This is the start of a program designed to get a list of processes.  Any 
idea why I am not getting the hash of counter names?

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


Re: problem with TERM::ReadKey

2005-03-29 Thread Lyle Kopnicky
Jezebel wrote:
problem is, i can not compile the TERM::ReadKey from
source.  whoever wrote it thought that Microsoft's
Visual C++ was a good build environment.  Since I
don't have Visual C++, my nmake always fails at the
cl.exe command.  I tried spoofing it to my c++.exe and
removing some switches, but then it fails on the
link.exe command.  I am not a C++ programmer, so now
I'm stuck.  (My work is also not going to buy me
MSVC++ just so i can compile one stinkin perl module
either.)
 

You can download the Visual C++ compiler for free from Microsoft.  Only 
the IDE costs money.

   http://msdn.microsoft.com/visualc/vctoolkit2003/
Regards,
Lyle Kopnicky
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Failed to AUTOLOAD

2005-03-23 Thread Lyle Kopnicky
Never mind, I fixed the problem.  The proper method name is 'stayOnTop', 
not 'StayOnTop'.

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


Failed to AUTOLOAD

2005-03-23 Thread Lyle Kopnicky
Hi folks,
I wanted to use Tk::StayOnTop, so I installed the module using PPM.  It 
depended on Win32::API, so I had to install that as well.  My program 
includes the following lines:

use Tk;
use Win32::API;
use Tk::StayOnTop;
 some TK code 
$mw->StayOnTop();
.
The interpreter chokes on the StayOnTop line, saying:
Assuming 'require Tk::StayOnTop;' at ...
Failed to AUTOLOAD 'Tk::Widget::StayOnTop' at ...
I don't know why it needed to "assume require" since I have a "use" 
statement in there.  And why did it fail to autoload?  Any ideas?

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


Re: No title bar?

2005-03-23 Thread Lyle Kopnicky
Thanks to both of you for your help.  I chose the Tk method.
Regards,
Lyle Kopnicky
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


No title bar?

2005-03-23 Thread Lyle Kopnicky
Hi folks,
Does anyone know how to create a window without a title bar in Tk?
If not Tk, then maybe Win32::GUI or wxPerl?
Thanks,
Lyle Kopnicky
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Autoflush

2005-03-11 Thread Lyle Kopnicky
$Bill Luebkert wrote:
Lyle Kopnicky wrote:
 

Hi folks,
Autoflush doesn't seem to be working.  I have written a server program 
which outputs logging information to the console.  When I redirect it to 
a file, the file stays size zero until a lot of stuff is in it.  
Typically I stop the program by killing it, and that doesn't cause the 
buffer to flush.

I've set $| = 1 at the start of the program, but that doesn't help.  I'm 
trying to avoid changing all the prints to print to a filehandle, but I 
may have to do that.  Any ideas?
   

$| only works on the currently selected FH.  You should wait until you
open LOG and then do it:
open LOG, 'fubar.log' ...
select ((select (LOG), $| = 1)[0]); # temp select LOG and revert 
after $|
 

Thanks, Bill.  I was trying to set it on STDOUT, not LOG.
I have since changed my program to "select(LOG)" and it works fine.
I don't know why it didn't work on STDOUT, though (when I was 
redirecting it to a file from the command line).

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


select function

2005-03-11 Thread Lyle Kopnicky
The select function isn't behaving the way I expect.  I sent some text 
on a socket, then wanted to wait to see when the response was available, 
with a timeout.  I wrote code like this:

my $rin = "";
vec($rin, fileno($socket), 1) = 1;
if (select($rin,"","",$MessageTimeout) == 0) {
   reopen connection...
}
Even though, without this check, I am getting responses every time, I 
wanted to put in this check to deal with a timeout situation.  This 
check times out, even though I know there is incoming text available on 
the socket.

However, if I switch it to select("",$rin,"",$MessageTimeout), the test 
succeeds.  In other words, if I wait to be able to write instead of to 
read.  Well, that doesn't mean a lot - it should always be available for 
writing.

Is this just a quirk of Perl on Windows?  Or am I doing something wrong?
Thanks,
Lyle Kopnicky
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Autoflush

2005-03-11 Thread Lyle Kopnicky
Well, it doesn't work for me.  It's the same as not using it - I get no 
output in my log file.  Not very useful.  :(

- Lyle
Craig Cardimon wrote:
I use "$| = 1;" myself. It works well enough. There is a thing with 
the buffer and memory and all that fun stuff.

It doesn't always function as quickly or as smoothly as I would like 
it to, but it is much better than not using it.

-- Craig
Lyle Kopnicky wrote:
Hi folks,
Autoflush doesn't seem to be working.  I have written a server 
program which outputs logging information to the console.  When I 
redirect it to a file, the file stays size zero until a lot of stuff 
is in it.  Typically I stop the program by killing it, and that 
doesn't cause the buffer to flush.

I've set $| = 1 at the start of the program, but that doesn't help.  
I'm trying to avoid changing all the prints to print to a filehandle, 
but I may have to do that.  Any ideas?

Thanks,
Lyle Kopnicky

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


Autoflush

2005-03-11 Thread Lyle Kopnicky
Hi folks,
Autoflush doesn't seem to be working.  I have written a server program 
which outputs logging information to the console.  When I redirect it to 
a file, the file stays size zero until a lot of stuff is in it.  
Typically I stop the program by killing it, and that doesn't cause the 
buffer to flush.

I've set $| = 1 at the start of the program, but that doesn't help.  I'm 
trying to avoid changing all the prints to print to a filehandle, but I 
may have to do that.  Any ideas?

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


Re: Intercept IE or Netscape

2005-02-08 Thread Lyle Kopnicky
Jerry Kassebaum wrote:
This may be a socket question.
Is there a way to read the data coming into my computer to a file on 
its way to my browser?  Is there a way to intercept what the browser 
is going to send to the internet, change it, and then send it out? 
Man, that would make scraping the internet a piece of cake!

Jerry Kassebaum
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
You need to create a proxy server.  Write a program that will process 
the requests that come from your browser, then pass them off to the 
remote sites.  And respond to what's coming back, process it then return 
it to your browser.  Just set up the proxy to sit on some local port, 
and configure your browser to use it as a proxy.

There are existing proxies that may be configured to do what you want - 
maybe you won't have to write one.

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


Re: Deleting a worksheet in Excel

2005-01-24 Thread Lyle Kopnicky




[EMAIL PROTECTED] wrote:

  Hi;
  Don't most OO structures require
constructor
and destructor methods? Seems to me this is OK for OO. Requiring the
Workbook
to delete the Worksheet leads to a different problem...that of a
WorkBook
with no Worksheets. Since the raison d'etre for a WorkBook is as a
container
for WorkSheets, the coding to account for that could be even worse.
  
  Just my 2 cents worth.
  
  Later,
  
  
  John Wunderlich
  
You make some good points.  However I must point out that the
constructor is called on the class, not on the object.  And the
destructor is never explicitly invoked.  And as Chris Jones pointed
out, you face the problem of empty Workbook even if you tell a
Worksheet to delete itself... only how does the Worksheet know it
is the only one?

Regards,
Lyle


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


Re: Deleting a worksheet in Excel

2005-01-24 Thread Lyle Kopnicky
Hsu, David wrote:
Hi,
Can someone let me know the syntax of deleting a worksheet in an Excel 
workbook.  I am using Win32::OLE.
I've tried:
$Workbook->Worksheets{9}.Delete;
 
Thanks,
David
This is an aside, not an attempt to answer your question, but:
Doesn't anyone think it's a bit odd to tell a Worksheet to delete 
itself?  It's like asking someone to shoot themselves and then bury 
themselves.  The object has no context to do such a thing.  Shouldn't we 
be telling the Workbook to delete the Worksheet?  Something like 
$Workbook->DeleteWorksheet(9)?

Bill Gates, are you listening?  You are violating OO common sense!
- Lyle
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Sleep()

2005-01-14 Thread Lyle Kopnicky
Chris wrote:
Is there a way make Perl sleep for less than a full second?
I'm using v5.8 on win2k.
- Chris
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

Just use a fractional value, e.g. sleep(.5).  That may not be the 
official behavior, but it worked for me, using v5.8 on NT 4.

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


Re: Win32::AdminMisc still doesn't work

2005-01-12 Thread Lyle Kopnicky
Lyle Kopnicky wrote:
Never mind, I found it, downloaded it, put it in my C:\Windows\System 
directory, and the module now works.

I hope the same will work on NT 4.0.  I wonder why MSVCR70.dll isn't 
mentioned in the documentation for Win32::AdminMisc, and isn't 
installed automatically by PPM.
Nope, it still doesn't work on NT 4.0 TSE.  I still get:
   perl.exe - Entry Point Not Found
   The procedure entry point GlobalMemoryStatusEx could not be located 
in the dynamic link library KERNEL32.dll.

As most of our customers' servers are NT 4.0 TSE, we are out of luck if 
we can't get this to work.  Any idea why we're getting that error?

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


  1   2   >