Re: Keeping hash in insertion order, using Tie-IxHash

2002-09-26 Thread $Bill Luebkert

Gary Nielson wrote:
> I have an array I've created that contains 10 years of annual eps data for
> companies. A perl script then calculates the percentage growth rate from
> year to year and pushes the results into @results. 
> 
> I then combine the two arrays into a hash (using tutorial I found at
> http://tlc.perlarchive.com/articles/perl/ug0001.shtml and want to print a
> table with the results. But the results aren't in order. The cookbook
> (5.6) talks about tieing, but I've tried and don't understand.
> 
> Any suggestions, advice, help appreciated. Here's the script where I
> attempt to tie. If I should include the earlier script that creates the
> two arrays, I will send that along, too:
> 
> # @decade contains 10 years eps - 0 is latest, 9 is earliest
> # results contains the results of calculating % growth rate from year to
> # year. unless negative
> 
> # combine 2 arrays into hash
> @annual{ @decade } = ( @results );
> 
> # cookbook 5.6
> # this obviously isn't working, I do not understand how to use
> tie %annual, "Tie::IxHash";
> # manipulate %HASH;
> @keys = keys %annual;
> 
> #print table to file
> 
>   print RESULTS "\n";
>   print RESULTS "Annual earnings table\n";
>   print RESULTS 
>"YREPSPERCENT\n";
>   while (($key, $value) = each %annual ) {
>   $count++;
>   print RESULTS 
>"$count$key$value\n";
>   }
>   print RESULTS "@results@decade"; 
>   print RESULTS "\n";
> }

This should work (I didn't bother using the tie):

use strict;
my @decade = qw(a b c d e f g h i j);
my @results = qw(0 1 2 3 4 5 6 7 8 9);

my %annual;
@annual{@decade} = @results;

# assumes RESULTS is already open

print RESULTS "\n";
print RESULTS "Annual earnings table\n";
print RESULTS "YREPSPERCENT\n";
my $count = 0;
while (my ($key, $value) = each %annual) {
$count++;
print RESULTS "$count$key$value\n";
}
print RESULTS "@results@decade"; 
print RESULTS "\n";

__END__

-- 
   ,-/-  __  _  _ $Bill Luebkert   ICQ=162126130
  (_/   /  )// //   DBE Collectibles   Mailto:[EMAIL PROTECTED]
   / ) /--<  o // //  http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_http://www.todbe.com/

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



Keeping hash in insertion order, using Tie-IxHash

2002-09-26 Thread Gary Nielson

I have an array I've created that contains 10 years of annual eps data for
companies. A perl script then calculates the percentage growth rate from
year to year and pushes the results into @results. 

I then combine the two arrays into a hash (using tutorial I found at
http://tlc.perlarchive.com/articles/perl/ug0001.shtml and want to print a
table with the results. But the results aren't in order. The cookbook
(5.6) talks about tieing, but I've tried and don't understand.

Any suggestions, advice, help appreciated. Here's the script where I
attempt to tie. If I should include the earlier script that creates the
two arrays, I will send that along, too:

# @decade contains 10 years eps - 0 is latest, 9 is earliest
# results contains the results of calculating % growth rate from year to
# year. unless negative

# combine 2 arrays into hash
@annual{ @decade } = ( @results );

# cookbook 5.6
# this obviously isn't working, I do not understand how to use
tie %annual, "Tie::IxHash";
# manipulate %HASH;
@keys = keys %annual;

#print table to file

print RESULTS "\n";
print RESULTS "Annual earnings table\n";
print RESULTS 
"YREPSPERCENT\n";
while (($key, $value) = each %annual ) {
$count++;
print RESULTS "$count$key$value\n";
}
print RESULTS "@results@decade"; 
print RESULTS "\n";
}






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



RE: Calling WMI Methods with Win32::OLE

2002-09-26 Thread Gibb, Thomas A








Dave Roth has two excellent books that
cover these and other topics in great detail.

 

Check out his site at www.roth.net. Really good information as well
as excellent modules.

 



Tom Gibb 
  



-Original Message-
From: Scott Campbell
[mailto:[EMAIL PROTECTED]] 
Sent: Thursday,
 September 26, 2002 8:35 AM
To: [EMAIL PROTECTED]
Subject: Calling WMI Methods with
Win32::OLE

 

I have looked everywhere to find an
example of how to call a "method" in WMI with perl, and have been
unsuccessful.

 

Does anyone know if it can be done,
and if so, have an example?

 

For example, the
Win32_ComputerSystem class has a "Rename" method to rename the
computer.

 

Scott Campbell

Senior Software Developer

Somix Technologies

(207) 324-8805

http://www.somix.com

 








Writing a file in UTF-8

2002-09-26 Thread desarrollo

Hi!

I just wondered if there is a way to write a file in UTF-8 encoding. Like
when you save a file in Notepad in UTF-8

I want to do somthing similar to this but to save it in UTF-8 encoding:

open (FILE, ">new.txt");
print FILE "ella está aquí";
close (FILE);

Is there a parameter or something to make this file to be saved in UTF-8
so the international chars are saved in their encoding type?

Thanks in advance,
Mauricio

Thanks in advance,
Mauricio

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



Re: Any help appreciated - unusual cookie request

2002-09-26 Thread $Bill Luebkert

Ron Grabowski wrote:
>>set expire to 01/01/2045. Any and all observations appreciated.
> 
> 
> What does this have to do with Perl-Win32-Admin or Perl-Win32-Users? I
> think its a -Web related question at best.

Although he tried to cross-post, they all went to web and resulted
in a single post.  :)

-- 
   ,-/-  __  _  _ $Bill Luebkert   ICQ=162126130
  (_/   /  )// //   DBE Collectibles   Mailto:[EMAIL PROTECTED]
   / ) /--<  o // //  http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_http://www.todbe.com/

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



Re: Calling WMI Methods with Win32::OLE

2002-09-26 Thread Thomas R Wyant_III


"Scott Campbell" <[EMAIL PROTECTED]> wrote:

> I have looked everywhere to find an example of how to call a
> "method" in WMI with perl, and have been unsuccessful.

> Does anyone know if it can be done, and if so, have an example?

Yes, it can be done. The following script lists all process IDs, and the
SID of the user of each. The method call is

$proc->GetOwnerSid ($sid)

The Variant stuff is in there because that's the way this particular method
is called. See the docs for the signatures.

Note also that this method returns FALSE for success; this is why we
extract the string from the variant "unless" the call returns TRUE.


use Win32::OLE qw{in with};
use Win32::OLE::Const 'WMI';  # If needed
use Win32::OLE::Variant;  # If needed

my $mach = shift @ARGV || ".";# Or whoever

my $olecls
= "winmgmts:{impersonationLevel=impersonate,(Debug)}!//$mach/root/cimv2";
my $wmi = Win32::OLE->GetObject ($olecls) or
die "Error - Win32::Process::Info::WMI failed to get winmgs object from
OLE: ",
  Win32::OLE->LastError;

my $sid = Variant( VT_BYREF | VT_BSTR, '');
foreach my $proc (in $wmi->InstancesOf ('Win32_Process')) {
my $oid = '';
$oid = $sid->Get () unless $proc->GetOwnerSid ($sid);
print "$proc->{ProcessId}\t$oid\n";
}
print "Done.\n";

Tom Wyant



This communication is for use by the intended recipient and contains 
information that may be privileged, confidential or copyrighted under
applicable law.  If you are not the intended recipient, you are hereby
formally notified that any use, copying or distribution of this e-mail,
in whole or in part, is strictly prohibited.  Please notify the sender
by return e-mail and delete this e-mail from your system.  Unless
explicitly and conspicuously designated as "E-Contract Intended",
this e-mail does not constitute a contract offer, a contract amendment,
or an acceptance of a contract offer.  This e-mail does not constitute
a consent to the use of sender's contact information for direct marketing
purposes or for transfers of data to third parties.

 Francais Deutsch Italiano  Espanol  Portuges  Japanese  Chinese  Korean

http://www.DuPont.com/corp/email_disclaimer.html


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



Re: Error with $Response->Flush()

2002-09-26 Thread Jan Dubois

On Thu, 26 Sep 2002 16:13:50 -0400, Ron Grabowski <[EMAIL PROTECTED]> wrote:

>> >And as you mentioned the 256 bytes most definetely need to be sent before
>> >anything will flush.
>> 
>> It is actually Internet Explorer that needs to receive 256 bytes before
>> displaying anything.  If you test your page with a different browser (like
>> Mozilla), you'll see that the Flush() works with less data too.
>
>How did you know that? Are quirks of IE and other Microsoft products
>documented anywhere? I wouldn't know where to start in the MSDN.

It is not documented as far as I know.

I know this because I rewrote the ActiveState Visual Package Manager from
scratch (For Komodo 2.0 Professional and PDK 5.0).  It uses HTTP::Daemon
to act as a mini webserver.  When you install/upgrade/remove packages, I
wanted to see some kind of progress report in the browser window.  I could
see this immediately on Mozilla, but on IE only after a couple of packages
had been processed.

After changing the code to something like this, everything works on IE,
Mozilla (and Opera, if we ignore keyboard events):

my $res = HTTP::Response->new($RC_OK, $MSG_OK, $headers, undef);
$conn->send_response($res);

print $conn <
  
Visual Package Manager

var baseurl="$baseurl";

  
  






HTML


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



Re: Error with $Response->Flush()

2002-09-26 Thread Ron Grabowski

> >And as you mentioned the 256 bytes most definetely need to be sent before
> >anything will flush.
> 
> It is actually Internet Explorer that needs to receive 256 bytes before
> displaying anything.  If you test your page with a different browser (like
> Mozilla), you'll see that the Flush() works with less data too.

How did you know that? Are quirks of IE and other Microsoft products
documented anywhere? I wouldn't know where to start in the MSDN.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: HTML::Parser question

2002-09-26 Thread Ron Grabowski

> use strict;
> use HTML::Parser 3.00 ();

Thank you for posting some HTML::Parser code. For as long as I've been
doing Perl I've only seen "real" HTML::Parser code a handful of times.
People are quick to say "just use HTML::Parser". If most people are
anything like me, I just end up using some regexs and a few substr()s to
hack out what I want. Its good to see people actually using such a
talked about module.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Any help appreciated - unusual cookie request

2002-09-26 Thread Norris, Joseph

Here is the situation: I am on an network of windows boxes with apache
running on one of the boxes. I have my web apps there with perl/mysql etc..
I want to build a script that will be run in the users login script that
will take the username via $ENV{USERNAME} and build a cookie do a request to
the server so that the cookie will be built on the users box containing the
user's USERNAME, so that I can use cgi->cookie and know who is there. What I
have attempted so far. I have a cookie built on the opening page of my
intranet site. The cookie contains a bogus value. In the login script I had
a script that runs out and finds the cookie file no matter where it is on
the user's disk, slurps it and writes it back out with the $ENV{USERNAME}. I
use all the same delimiters for records etc and the file looks exactly the
same (or so I think) as the original cookie file. However the browser spots
the different fast - won't access the cookie and then trashes even when I
set expire to 01/01/2045. Any and all observations appreciated. 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs