RE: grep

2001-06-04 Thread Jesse Sookne

Tanya,

If all you want to do is add header info to the top of a bunch of files, you
could use something like the script below, which is simpler than using grep,
etc.

The script below would be invoked as (for example):
perl header.pl C:\*.c D:\*.cpp

Hope this helps,
Jesse



#Begin Script
#!/usr/bin/perl

use strict;
use warnings;

my @files;
foreach (@ARGV) {   #look through each arg passed on the cmd line
push @files, glob($_);  #and do wildcard expansion on them.
}   #(i.e. "C:\*.pl" becomes a list of all files in 
#the C:\ directory which end in ".pl".

undef $/;
my $header = "Insert your header info here...\n";
foreach (@files) {
#Read the contents of the file.
open FILE, "$_" or die "Error: Couldn't open $_ for reading: $!\n";
my $text = ;
close FILE;

open FILE, ">$_" or die "Error: Couldn't open $_ for writing: $!\n";
$text = $header . $text;#attach the header at the top of the file,
print FILE $text;   #and write the new version of the file.
close FILE;
}
#End Script


-Original Message-
From: Tanya Graham [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 04, 2001 11:48 AM
To: 'Arthur Cohen'; [EMAIL PROTECTED]
Subject: RE: grep


this is how it is called:
AddHeader.pl -f [directory name] -e [extension list]
this tells the program to add a header to the files with extensions
"extension list" in "directory name".  I would actually prefer to have them
comma separated, so can you explain how to replace the commas with "|"? i
know i've seen that function before, but i can't remember what it is
called...
thanks
tanya

-Original Message-
From: Arthur Cohen [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 04, 2001 11:38 AM
To: [EMAIL PROTECTED]
Subject: RE: grep


: 

: 

: if i take the argument from a flag (so i won't be using 

: @ARGV, but opt_x)

: would i still be able to use join?



You can do what you want to do, but I'm not sure exactly what you're

trying to do. How are you calling the program from the command line, and

how are you pulling the command-line arguments into variables? If the

file extentions are already in a single scalar variable (e.g.

comma-separated or something) rather than an array like @ARGV, then you

may need to do a split first, then a join, or you may just be able to

separate your comma separator (or whatever) with a | character.



--Art

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



RE: filetest operators

2001-05-15 Thread Jesse Sookne

I suspect the -W and -w operators are only looking at the MS-DOS style
attributes of the directory, not the NT permissions.  I ran "attrib +r" on a
directory, and -W/-w returned false.  After running "attrib -r" on the
directory, they returned 1.

I think to get at the NT permissions, you'll need to use a Win32::* module
(not sure which one).

-Jesse


-Original Message-
From: Robert Meyer [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 15, 2001 2:36 PM
To: 'Carl Jolley'; Robert Meyer
Cc: '[EMAIL PROTECTED]'
Subject: RE: filetest operators


I chopped off the trailing backslash, and got the same result.  The file
doesn't exist, and the script should only attempt to create the file if I
have permissions to the directory -- which I don't.  

I'm running it myself from the command line.  I've run it on 2 different
machines running NT4 Workstation, and a similar script had the same problem
on 2 or 3 other NT4 Workstation machines.

As far as you can tell (and aside from the trailing backslash) am I using -w
properly?  Is it meant to be used on directories, or just files?

The mission here is to control the flow of a program based on a directory's
permissions.  At this point, -w and -W appear to return true no matter what
permissions I give my directory, as long as it exists.  I even tried testing
'c:\newdir\.' and got the same result.

Surely I've misunderstood something.  Surely there's some easy way to know
if a directory is writeable.

_
Rob Meyer

-Original Message-
From: Carl Jolley [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 15, 2001 4:40 PM
To: Robert Meyer
Cc: '[EMAIL PROTECTED]'
Subject: RE: filetest operators


On Tue, 15 May 2001, Robert Meyer wrote:

> I don't have ANY permissions on the directory.  Or rather, my permissions
on
> the directory are "No Access".  I shouldn't be able to read or write or
even
> list in that directory.  But
>
> I see what you mean: according to the output of my script, I do have write
> access to that directory.  The OS, however, tells me otherwise.
>
> _
> Rob Meyer
>
> -Original Message-
> From: Carl Jolley [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 15, 2001 2:59 PM
> To: Robert Meyer
> Cc: '[EMAIL PROTECTED]'
> Subject: Re: filetest operators
>
>
> On Wed, 9 May 2001, Robert Meyer wrote:
>
> > Hello,
> >
> > I'm experimenting with the filetest operators in Win32, and they don't
> seem
> > to work as I'd expect.  I have a directory that I have set to No Access
> for
> > everyone (don't worry, I'm the owner).  I have no permission in Windows
to
> > even look inside the directory or write files to it.  However, -w and -W
> > both evaluate to true on that directory.  What gives?
> >
> > Here's a snippet of code.  Notice that I test the file first, then write
> to
> > it.  This program always dies when I try to open the file.
> >
> > Any ideas?
> >
> > ### code>
> >
> > my $fn = "c:\\newdir\\file.txt";
> >
> > $fn =~ m#([^\\/]+)$#;
> > my $path = $`;
> > print "The path is: '$path'\n";
> >
> > # this is to show the result of the filetest
> > my $ft = -w $path;
> > print "Is it writeable: '$ft'\n";
> > my $ft2 = -W $path;
> > print "Is it Writeable: '$ft2'\n";
> >
> > if ($ft) {
> > open (NEWFILE, ">$fn") or die $!;
> > print NEWFILE "All your base are belong to us.\n";
> > close NEWFILE;
> > } else {
> > print "The directory is not writeable.\n";
> > }
> >
> > # < code
> >
> > ## output >
> > The path is: 'c:\newdir\'
> > Is it writeable: '1'
> > Is it Writeable: '1'
> > Permission denied at C:\Data\develop\Perlhax\fileio\simple.pl line 16.
> > # < output
> >
>
> It looks like you have permission to write on the directory, e.g. to
> create a new file in the directory but you don't have permission to
> write on the specified file.
>

Make sure you chop off the trailing slash before using the filetest
operator on it. The directory is 'c:/newdir' not 'c:/newdir/'.

Did you check to see if you have write access to the file? When you
are running the script are you running as your self or is the script
being run by a web server?

 [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
___
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: very basic TK ?

2001-05-09 Thread Jesse Sookne

Seems like there are two things you can do to correct this:

1) Change the line "use TK;" to "use Tk;" (make the "K" lowercase).
2) Change the line "MainLoop;" to "$mw->MainLoop;".

I'm not sure what the differences between TK and Tk are (or why there's two
Tk modules), but apparently the Tk module exports MainLoop as a function
while the TK module doesn't.  If you're going to use TK, then you have to
call it as a method (with the $mw->MainLoop syntax).

-Jesse


-Original Message-
From: Gregg Martinson [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 09, 2001 11:41 AM
To: [EMAIL PROTECTED]
Subject: very basic TK ?


Hello,  
I have been playing with TK today...reading the O'Reilly book on the
subject, and am now trying to work through some of the examples. I have
typed verbatim the "hello world" program.  It compiles and executes, but
quits before any GUI shows on the screen.  I'm sure that this is a
ridiculouly easy thing to fix, but I can't figure it out.  Here's the script
===
#! /usr/bin/perl
use TK;
my $mw=MainWindow->new;
$mw->title('Hello world');
$mw->Button(-text=>'done',-command=>sub{exit})->pack;
MainLoop;
===
Perl spins, and then returns me to the console prompt.  What gives? TIA
gregg
  





__
D O T E A S Y - "Join the web hosting revolution!"
 http://www.doteasy.com
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Threads in ASPerl build 623

2001-04-04 Thread Jesse Sookne

No problem, I just mean that ActiveState should document this in an obvious
place, because it's confusing and I've seen lots of people asking this.

Maybe someone from AS is monitoring the list and could improve the docs in
this area?

-Jesse


-Original Message-
From: Campbell [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 04, 2001 1:49 PM
To: [EMAIL PROTECTED]
Subject: RE: Threads in ASPerl build 623


(sorry..)

On Wed, 4 Apr 2001, Jesse Sookne wrote:

>See message below.  This is definitely a FAQ.
>
>-Jesse
>
>-Original Message-
>From: Jesse Sookne
>Sent: Thursday, March 29, 2001 11:17 AM
>To: 'Kirk Rogers'; Perl-Win32-Users2 (E-mail)
>Subject: RE: Multithreaded Apps on Win32?
>
>
>In perl 5.6, threads are implemented via the fork() emulation.  Read
perldoc
>perlfork for more info.
>
>The Thread module was used in previous versions, and is not compatible with
>5.6.
>
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Threads in ASPerl build 623

2001-04-04 Thread Jesse Sookne
Title: RE: Threads in ASPerl build 623





See message below.  This is definitely a FAQ.


-Jesse


-Original Message-
From: Jesse Sookne 
Sent: Thursday, March 29, 2001 11:17 AM
To: 'Kirk Rogers'; Perl-Win32-Users2 (E-mail)
Subject: RE: Multithreaded Apps on Win32?



In perl 5.6, threads are implemented via the fork() emulation.  Read perldoc perlfork for more info.


The Thread module was used in previous versions, and is not compatible with 5.6.





RE: Multithreaded Apps on Win32?

2001-03-29 Thread Jesse Sookne

In perl 5.6, threads are implemented via the fork() emulation.  Read perldoc
perlfork for more info.

The Thread module was used in previous versions, and is not compatible with
5.6.

-Jesse


-Original Message-
From: Kirk Rogers [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 29, 2001 11:14 AM
To: Perl-Win32-Users2 (E-mail)
Subject: Multithreaded Apps on Win32?


Hi folks,
I just started looking into the multithreaded capabilities (as limited as
they are documented) and discovered on my first basic attempt, that Threads
are not supported?  Hmmm, here's the output:

On an NT 2000 Server I get...

Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.

C:\>perl -v

This is perl, v5.6.0 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2000, Larry Wall

Binary build 623 provided by ActiveState Tool Corp.
http://www.ActiveState.com
Built 16:27:07 Dec 15 2000


Perl may be copied only under the terms of either the Artistic License or
the
GNU General Public License, which may be found in the Perl 5.0 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.


C:\>


And my test program is...

#
#/usr/bin/perl -w

use Thread;

my $thread1 = Thread->new(\&HELLO, "i am thread 1", 3);
my $thread2 = Thread->new(\&HELLO, "i am thread 2", 6);
$_->join foreach ($thread1, $thread2);
sub HELLO {
my ( $message, $loop ) = @_;
for ( 1..$loop ) {
print $message, "\n"; sleep 1;
}
}
##


And the error I get is:


E:\Perl\progs\testing>test_threads.pl
No threads in this perl at E:\Perl\progs\testing\test_threads.pl line 5.

E:\Perl\progs\testing>

Any clues as to what I have configured wrong?

Thanks,
Kirk





___
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: building a "time range" structure

2001-03-15 Thread Jesse Sookne

Hi Chuck,

Here's a quick hack that seems to work.  I'm sure there are better ways of
doing it though.

Anyway, hope this helps.

-Jesse



my %timeranges = (
1 => {  #network number
4 => { '_1159' => 4, '1200_2400' => 6 },#day 4 =
Thursday
5 => { '_1159' => 2, '1200_1800' => 1, '1800_2400' => 3 },  #day
5 = Friday.
},
);


my $network = 1;
my ($min, $hour, $day) = (localtime)[1, 2, 6];
my $time = sprintf("%2d%2d", $hour, $min);

my $max_connections = max_connections( $network, $day, $time ) or die;
print "max connections: $max_connections\n";

sub max_connections {
my ($network, $day, $time) = @_;

foreach my $range (keys %{ $timeranges{$network}{$day} }) {
my ($begin_time, $end_time) = split(/_/, $range);
if (($time >= $begin_time) and ($time <= $end_time)) {
return $timeranges{$network}{$day}{$range};
}
}

return undef;
}
###



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 15, 2001 12:35 PM
To: [EMAIL PROTECTED]
Subject: building a "time range" structure


Hello all,

I've run into sort of an odd problem.  I'm designing a file retrieval
system and one of the requirements it that it is kind to the network.  To
assure it follows the rules I need to build a data structure from a
database that hold the network throttle rates (how many max connections
he's allowed) for time ranges.

the database structure is as follows:

network_number, day_of_week_number, start_time, stop_time, throttle_rate

some example values would be:

1,0,,2400,8 <-- network 1, sunday, from midnight, to midnight, 8
total connections
1,1,,1200,4 <-- network 1, monday, from midnight, to noon, 4 total
connections
1,1,1200,2400,8 <-- network 1, monday, from noon, to midnight, 8 total
connections


Each day of week must have enough entries to add up to 24 hours time, and
they can have as many entries as needed to accomplish that.

what I want to build is a structure that can be used to get the throttle
rate without having to hit the database more than once (to initially
construct it).

The stumbling block I've hit is with the start and stop time ranges - I see
the structure being something like:

%networks{
 %day_of_week{
  SOME TIME RANGE THING
   $throttle_rate

so... a hash keyed by network number, storing hashrefs keyed by day of
week, storing SOMETHING to handle the time ranges, ending with the throttle
rate for that time range.  You should be able to do something like:

my $throttle_rate = $networks{1}->{0}->{current time thing}  # get throttle
rate for network 1, Sunday, and current time

the problem is how to determine the proper time range by only having the
current time.  You can't directly equate the current time with a "range"
and that's what I need to solve for.  I don't want to use Date::Manip if I
can avoid it, and I'm not sure it would help in this case as we're just
using 24 hour time stamps and I'm not sure how date::manip handles those.
Does anyone have any thoughts?  Sorry for this huge post!

Chuck

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



RE: How do I use threads

2001-03-05 Thread Jesse Sookne

Oops, non-HTML version follows.

-Jesse

-Original Message-
From: Jesse Sookne 
Sent: Monday, March 05, 2001 11:29 AM
To: 'Peter Guzis'; 'Robert Follis';
'[EMAIL PROTECTED]'
Subject: RE: How do I use threads


Actually, threads are implemented in ActivePerl 5.6, but not with the
Threads module, which as far as I know is only for the 5xx builds of
ActivePerl.

In AP 5.6, you can use threads through the fork() emulation.  Read 'perldoc
perlfork' for more info.

-Jesse

-Original Message-
From: Peter Guzis [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 05, 2001 10:02 AM
To: '[EMAIL PROTECTED]'
Subject: RE: How do I use threads


Threads are disabled in AP 5.6 as of yet.  If you absolutely need this
functionality you'll either need to downgrade to 522, wait for Perl 6, or
hope for a 5.x build supporting threads. 

Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
email: [EMAIL PROTECTED]
www.encad.com

-Original Message-
From: Joe Schell [mailto:[EMAIL PROTECTED]]
Sent: Sunday, March 04, 2001 3:30 PM
To: Robert Follis
Cc: [EMAIL PROTECTED]
Subject: Re: How do I use threads


Robert Follis wrote:
> 
> I'm using perl 623 and the tutural example of using threads:
> ...
> 
> When I run the script it bombs out and says "No threads in this perl at
> test.pl line 3." Now I'm assuming that when I downloaded the binary and
> installed it that the binary would already include the thread option. Can
> someone help? Please e-mail me back if anyone has any ideas.
> 

And you installed the binary that supports threads right?  Not the other
one?
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: How do I use threads

2001-03-05 Thread Jesse Sookne
Title: RE: How do I use threads





Actually, threads are implemented in ActivePerl 5.6, but not with the Threads module, which as far as I know is only for the 5xx builds of ActivePerl.

In AP 5.6, you can use threads through the fork() emulation.  Read 'perldoc perlfork' for more info.


-Jesse


-Original Message-
From: Peter Guzis [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 05, 2001 10:02 AM
To: '[EMAIL PROTECTED]'
Subject: RE: How do I use threads



Threads are disabled in AP 5.6 as of yet.  If you absolutely need this
functionality you'll either need to downgrade to 522, wait for Perl 6, or
hope for a 5.x build supporting threads. 


Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
email: [EMAIL PROTECTED]
www.encad.com


-Original Message-
From: Joe Schell [mailto:[EMAIL PROTECTED]]
Sent: Sunday, March 04, 2001 3:30 PM
To: Robert Follis
Cc: [EMAIL PROTECTED]
Subject: Re: How do I use threads



Robert Follis wrote:
> 
> I'm using perl 623 and the tutural example of using threads:
> ...
> 
> When I run the script it bombs out and says "No threads in this perl at
> test.pl line 3." Now I'm assuming that when I downloaded the binary and
> installed it that the binary would already include the thread option. Can
> someone help? Please e-mail me back if anyone has any ideas.
> 


And you installed the binary that supports threads right?  Not the other
one?
___
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: Serial Number

2001-03-02 Thread Jesse Sookne

You could use ARP -A to gather MAC addresses without the need for rsh.  When
you ping a machine (or make contact with it over the network in some other
way), that machine's IP and MAC addresses are stored in the ARP table on
your machine.

So, you could write a script that goes through a list of machines (either IP
addresses or hostnames), pings them one by one, then calls ARP and gathers a
list of their MAC addresses.

I'm too tired to write it at the moment, but it should be a really easy
script.

-Jesse



-Original Message-
From: Christopher Hahn [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 02, 2001 6:22 PM
To: [EMAIL PROTECTED]
Subject: RE: Serial Number



Ron,

I guess that you have a solution, in parts.

i.e. to check the address of the remote machine ntbuild1:
==
@buff = `rsh ntbuild1 ipconfig /all`;
foreach (@buff) {if (/.*Physical Address.*\: (.+)$/) {print $1;}}
==
Returns:
==
C:\EXPORT>perl perltest2.pl
00-A1-C9-EC-20-D7
==

The only remaining issue would be to provide a
rsh daemon for NT.  The one I used is $45.00 from 
denicomp, but I am betting that gnu or some such
has similar.

Good luck,

Christopher

P.S. btw I know that there are umpteen tinier regexps that
would work.  Guru's may post them freely, as I wouldn't
mind seeing them as well.  (a scalar buffer and /s comes to mind)

> -Original Message-
> From: Jesse Sookne [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 02, 2001 5:24 PM
> To: 'Ron Grabowski'; [EMAIL PROTECTED]
> Subject: RE: Serial Number
> 
> 
> In NT, there's ARP.EXE that comes with the OS (at least, my 
> version of the
> OS -- NT 4.0 Server, SP 6a).  Try running arp -a.
> 
> Also, 'ipconfig /all' will show the local machine's MAC address.
> 
> I'm not sure how to do any of this through perl.
> 
> -Jesse
> 
> 
> 
> -Original Message-
> From: Ron Grabowski [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 02, 2001 3:16 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Serial Number
> 
> 
> > Accessing the Hardware Address of the Network Interface 
> Card will give you
> a
> > truly unique number for any make of machine, (12 digit 
> hex), however the
> > method for extracting the address might be different 
> depending on the
> > manufacturer of the Network Interface Card. If you were to get the
> machines
> > TCP/IP address you could then use ARP to get the hardware 
> address (this
> > approach would work even with changing TCP/IP addresses).
> 
> Does anyone on the list know how to do this?
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
> 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Win32::OLE And Windows Media Encoder Conundrum

2001-03-02 Thread Jesse Sookne

Hello Troy,

Below is the text of a message from Jan Dubois, answering a question I asked
a while ago that's similar to your question.

Hope this helps,
Jesse


-Original Message-
From: Jan Dubois [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 23, 2000 6:43 PM
To: Jesse Sookne
Cc: '[EMAIL PROTECTED]'
Subject: Re: [OLE] How to assign to a method? 


On Wed, 23 Aug 2000 17:00:44 -0700, Jesse Sookne <[EMAIL PROTECTED]>
wrote:

>Does anyone know if, using the Win32::OLE module, there's a way to assign
to
>a _method_ of an OLE object, instead of a property?
>
>I know from the Win32 OLE FAQ that one can do
>"object->method(argument)->{property} = value;"
>
>to assigned to a property.  But I have some VisualBasic code that does 
>"object.method(argument) = value;"

You cannot assign to a method.  But there are properties taking
parameters, and you might be running into one of those.  Please try:

$object->SetProperty("method", $argument, $value);

-Jan


___
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



how to check if a thread (pseudo-process) is still running

2001-02-19 Thread Jesse Sookne

Hello all,

I've been making my first foray into using threads in Win32 Perl with the
fork() emulation.  I'm trying to figure out a way to test if my child
threads are still executing, or have exited.  The perlfork documentation
gave me the impression that I could use 
 
kill(0, $pid);

to do this.  However, this doesn't seem to be working.  I believe kill() is
supposed to return 0 if the process/thread can't receive a signal (it's
exited), and 1 if it can (it's still running).  But I get 1 no matter if the
child pseudo-process has exited or not.  Below is a script that demonstrates
the problem:


my $pid = fork();
if ($pid != 0)  {
print "PARENT: Created child with process id $pid.\n"; 
sleep 2;
print "PARENT: Kill: ", kill(0, $pid), "\n";
sleep 7;
print "PARENT: Kill: ", kill(0, $pid), "\n";
} else { 
sleep 5;
print "CHILD: Exiting.\n";
exit();
}
#

Note that kill(0, $pid) does return 0 if I give it a PID that's never
existed.

Any ideas about why this is happening, or ways to work around it, would be
much appreciated.

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



RE: dereferencing hash problem

2000-12-07 Thread Jesse Sookne



Sorry for the HTML versionPlain text version follows.

You've constructed your hash wrong, which is why you're not able to get the
data out of it.

The lines

%win2k_counters= {
'CommitedBytesInUse'=>  "\\Memory\\ Committed Bytes In Use",

'MbytesAvail'   =>  "Memory\\Available MBytes",
};

create a hash with only one key which is a reference to an anonymous hash,
and that key has no value.  This is because the '{' character used in
"%win2k_counters = {" (and it's mate, '}', used a couple lines below that)
creates an anonymous hash.  What you should've done is use the '(' character
to create a normal hash, not the '{' character.

Also, if you run the above code with warnings turned on (perl -w or use
warnings if you're running perl 5.6), you'd get the warning

Reference found where even-sized list expected at ...

which would help you figure out the problem.  It's always a good idea to run
your code with warnings turned on, at least until you've finished developing
and debugging it.

So, your code, changed so that you're dealing with a normal hash and you can
get the data out of it the way you expected to, would be:

###
%win2k_counters= (
'CommitedBytesInUse'=> "\\Memory\\ Committed Bytes In Use", 
'MbytesAvail'   => "Memory\\Available MBytes",
);

while (($key, $value) = each (%win2k_counters)) {
print "The key is $key and the value is $value\n";
}



-Jesse Sookne


-Original Message-
From: Martin, James S. [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 07, 2000 4:45 PM
To: Perl-Win32-Users Mailing List (E-mail 2)
Subject: dereferencing hash problem


The following code produces this result:

"The key is HASH(0x3649f4) and the values is"


Of course I'd like to see the actual key name and value..  What am I doing
wrong?

Thanks,

James


%win2k_counters= {

'CommitedBytesInUse' => "\\Memory\\ Committed Bytes In Use", 
'MbytesAvail'   =>  "Memory\\Available MBytes",
};



while (($key, $value) = each (%win2k_counters)) {
print "The key is $key and the value is $value\n";}
___
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



testing

2000-12-07 Thread Jesse Sookne

testing to see if this comes out in HTML or plain textplease ignore.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: :UserAgent Won't run from browser

2000-10-06 Thread Jesse Sookne
Title: RE: :UserAgent Won't run from browser





I noticed one thing in your script: you have 


print "Context-type: text/html\n\n";


It should be "Content-type", not "Context-type".


-Jesse Sookne


-Original Message-
From: G M [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 28, 2000 7:25 AM
To: Perl Win32 Users
Subject: LWP::UserAgent Won't run from browser



The following code runs fine from NT 32-bit shell
cmd.exe but not when called from a browser.  Is this
code impossible to execute from the browser?


Just like Jan Dubois' T-Bond.pl example, I would like
to parse then cut and paste only the info I want to
see.


Your input is appreciated.


Gan




__Begin Script__


use LWP::UserAgent;


my $ua = new LWP::UserAgent;
my $url = 'http://www.yahoo.com';
my $req = new HTTP::Request 'GET', $url;
my $res = $ua->request($req);
my $file = $res->content;


print "Context-type: text/html\n\n";
print "\n";
print "Start\n";
print $file;
print "Done\n";
print "\n";


__End Script__


__
Do You Yahoo!?
Yahoo! Photos - 35mm Quality Prints, Now Get 15 Free!
http://photos.yahoo.com/
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users