Re: Perl script hogging CPU in WinNT

2000-11-22 Thread Carl Jolley

On Wed, 22 Nov 2000, Stuart MacCallum wrote:

> Hi and thanks to all that reply in advance.
> 
> This should be an easy one to all those who are experienced in perl.
> 
> I have written a perl script that runs as a background process on the win32
> platform. Unfortunately it is hogging all of the CPU time and I am having
> problems trying to stop this.
> 
> I am using the win32 module in the following way to start the
> "eventhandle.pl" script, which runs constantly in the background.
> 
> Win32::Process::Create($val, 'D:\\perl\\bin\\perl.exe', "perl
> eventhandle.pl",
>  1, "CREATE_SUSPENDED", ".");
> $val->SetPriorityClass(IDLE_PRIORITY_CLASS);   # I thought this would make
> sure the process only worked when the system was idle
> 
> $val->Resume;
> 
> The eventhandle.pl script continually checks the contents of  the file
> "flag.txt" to see if there is an event it has to complete, if so it does it,
> if not it rechecks the file again. I believe this loop is where the problem
> arises, does anybody know how I could free up the processor, or at least
> give me a hint or an online resource to turn to
>

Try using the "sleep" function after each check of the file. Even if
you just do a sleep(1) it should free up the processor for other stuff.
By cheking less frequently, say every 10 for 15 seconds I think that
you won't even notice that it is running. A more robbust solution would
be to have the OS notify you program when the event occurs rather than
have the program repeatly check. 

 [EMAIL PROTECTED] 
 All opinions are my own and not necessarily those of my employer 

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



symbolic link question

2000-11-22 Thread Dan Jablonsky

Hi everybody,
I was offered an elegant solution to manipulate files
in a directory:


open(OUT,">>output_file") || die;
foreach $file (<*daily*>) { #match files with 'daily'
open(FILE,$file) || die;
while() {
#do something to that file;
print OUT;
}
close FILE;
}
close OUT;
--

What if I have symbolic links among my filenames? I
would like to get to the name of the file to which the
symlink is pointing and test for the same *daily*
pattern.
And a more basic question: how do I read the name of a
file "behind" a symbolic link and store it in some
variable?

Thanks a lot,
Dan

__
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Using Sendmail - inserting html isn't rendered

2000-11-22 Thread Carl Jolley

On Tue, 21 Nov 2000, byron wise wrote:

> I am able to send mail using Sendmail with no prob.  But now I want to
> insert html tags to change color of text, make things bold, even give a
> background color.  When I put them in as I would imagine the tags show up in
> the body..not rendered at all.  Is there a fix?  

HTML is just text. It only does it magic when an HTML-aware program
renders the text. So it depends on what program reads it. To see what
I mean, make sure the file has a .htm or .html extention then type
its full path name as part of a file:/// url in a browser location box.
The program you are using may be HTML aware but not recognize that the
file is HTML. Usually the use of the correct extention is the key to
making sure the file type is recognized.

 [EMAIL PROTECTED] 
 All opinions are my own and not necessarily those of my employer 

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



Re: regex... please

2000-11-22 Thread Carl Jolley

On Tue, 21 Nov 2000, Charles Maier wrote:

> How do I code a m//ig to hit on either a ';' or a "\r\n" or a "\n".. in that
> order???
>

I would code it as:

/(?:;|\r?\n)/;

 [EMAIL PROTECTED] 
 All opinions are my own and not necessarily those of my employer 

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



Re: Hash

2000-11-22 Thread Ian Taite

Here's an example I've used:

# Call a subroutine passing a hash of parameters:
$ResCode = &subExportDirectory({
 OutputFile   => 'DePriest.FullDirExport.tsv',
 AdminProgram => 'c:\\exchsrvr\\bin\\admin.exe',
 DirectoryService => 'YOUR_SERVER',
 BasePoint=> '/o=Your Org/ou=Your Site',
 ExportObject => 'Mailbox',
 InformationLevel => 'Full',
 HiddenObjects=> 'No',
 SubContainers=> 'Yes',
 CodePage => '437',
 ColumnSeparator  => '9',
 MVSeparator  => '37',
 QuoteCharacter   => '34',
});

#==
sub subExportDirectory{
# Called by: Step 10
# Calls: subLogMessage
# Params:
# Returns:
#==
my $refParams = $_[0];

if(!open(fhAdminINI,">ExportINI")){
return -1;
}else{
print fhAdminINI "[Export]\n";
print fhAdminINI
"DirectoryService=".$$refParams{'DirectoryService'}."\n";
print fhAdminINI "Basepoint=".$$refParams{'BasePoint'}."\n";
print fhAdminINI "ExportObject=".$$refParams{'ExportObject'}."\n";
print fhAdminINI
"InformationLevel=".$$refParams{'InformationLevel'}."\n";
print fhAdminINI "HiddenObjects=".$$refParams{'HiddenObjects'}."\n";
print fhAdminINI "Subcontainers=".$$refParams{'SubContainers'}."\n";
print fhAdminINI "CodePage=".$$refParams{'CodePage'}."\n";
print fhAdminINI
"ColumnSeparator=".$$refParams{'ColumnSeparator'}."\n";
print fhAdminINI "MVSeparator=".$$refParams{'MVSeparator'}."\n";
print fhAdminINI
"QuoteCharacter=".$$refParams{'QuoteCharacter'}."\n";
close(fhAdminINI);
};

# and the script goes on and on..

};


- Original Message -
From: "Rob Lawton" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, November 21, 2000 2:58 PM
Subject: Hash


> Apologies if my Email seems so very simply, bit like it's author really.
>
> I while ago, (about a month and a bit..), I sent in an Email asking about
> passing values between procedures and somebody replied that I should look
> into associated arrays / hashes.  I have been trying to grasp the Perl
hash
> but have a number of questions I'm having difficulty finding responses to
> with any docs I've been through.
>
> I know that if I call a procedure with "()" it passes no values to it,
> similarly if I pass a list between the "()" I will be passing the values
to
> the procedure, (when I have a locally scoped var anyway) but am I correct
> in believing that with a hash I can access the value's in the hash from
> within any procedure ? Is this not a waste of memory resources as the
> value's are ALWAYS sitting in memory and accessible like a globally scoped
> variable ?
>
> It's just that I'm going through old code of mine and substituting areas
of
> code I think are memory intensive with procedures that once have used the
> var will only pass the result on to the procedure that called it. Thus
> saving memory as the other variables are no longer needed on for that
> procedure and therefore globally scoped or passing around are wasting
> resources.
>
> Yours confused.
>
> Rob.
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
>

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



Re: PerlCtrl and VBA

2000-11-22 Thread Lee

I think you may find the ActiveState PDK list more helpful.

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



Re: Using Sendmail - inserting html isn't rendered

2000-11-22 Thread Philip Newton

byron wise wrote:
> I am able to send mail using Sendmail with no prob.  But now I want to
> insert html tags to change color of text, make things bold, 
> even give a background color.  When I put them in as I would
> imagine the tags show up in the body..not rendered at all.  Is
> there a fix?  

Yes. Mail by default is plain text (thank goodness!). If you want to send
HTML, you have to tell the receiving mail program that it's HTML, to
override the default. Try adding the following headers to your message:

Mime-Version: 1.0
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Modify the charset and the Content-Transfer-Encoding to suit your tastes.
For example, you might use charset=us-ascii and 7bit transfer encoding. Or
you might want quoted-printable transfer encoding. Use whatever reflects the
format of the text you are sending.

If you want to send the same message as both text and HTML, you have to do a
little bit more (or use a module (MIME::Lite?) that'll save you the work).

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



Re: DBI using cursors

2000-11-22 Thread Philip Newton

barons wrote:
> I have my Perl script set up to page through recordsets. 10 
> pages at a time. My SQL call is something like this.
> 
> SELECT column1, column2 FROM table.
> 
> Now each time the next or prev button is pressed this SQL 
> call is executed and searches through the table to find where
> it left off at.

Is this a CGI application? Or are the "buttons" provided by Tk or Win32::GUI
or something like that?

My guess is that it's a CGI environment, and then you have the problem that
HTTP is stateless.

> I want to use DBI with a cursor to mark the spot by 3 rows where
> it last left off at. I pretty sure that using a cursor will do
> this. Does anyone have a sample snippet of code using a cursor?

If you use DBI and DBD::, then you're probably using a cursor
already; you can fetch a row at a time, and fetch knows where you left off.

The problem with CGI is that if your script is called again, it's a whole
new copy with new variables, so the cursor is gone and you can't access it
any more.

For what you want, you need a persistent database connection. This may be
possible if you're running under something such as Apache + mod_perl, which
keeps the script in memory and can cache database connections. But for plain
CGI, you're stuck AFAIK.

If your environment is not CGI, ask again.

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