H
Henry Law
Running ActivePerl under Win XP; I'm trying to work out how to make
Perlscript do what Perl does (why doesn't it ... answers on a postcard).
Here's a sample script:
<Job ID="tryit">
<script language=PerlScript>
use strict;
use warnings;
use vars('$WScript'); # Avoid "strict" warnings
my $arg = $WScript->{Arguments};
my $countArgs = $arg->{Count};
open OUTPUT,">>tryit.log";
for(my $i=0; $i<$countArgs; $i++) {
$WScript->Echo($arg->Item($i));
#print OUTPUT "$arg->Item($i)\n";
}
</script>
</job>
Call it "tryit.wsf" and run it with "tryit.wsf one two three" and it
puts up messages boxes with "one", "two" and "three" in them, as desired.
Now comment out the $WScript->Echo line and remove the comment on the
line below it; I expect this to write "one", "two" and "three" to the
log file. Instead when I run "tryit.wsf one two three" I get the
following log file:
Win32::OLE=HASH(0x179cea0)->Item(0)
Win32::OLE=HASH(0x179cea0)->Item(1)
Win32::OLE=HASH(0x179cea0)->Item(2)
Can anyone help me find out why replacing this "Echo" thing with a print
statement apparently changes the data printed? I'm mystified.
Perlscript do what Perl does (why doesn't it ... answers on a postcard).
Here's a sample script:
<Job ID="tryit">
<script language=PerlScript>
use strict;
use warnings;
use vars('$WScript'); # Avoid "strict" warnings
my $arg = $WScript->{Arguments};
my $countArgs = $arg->{Count};
open OUTPUT,">>tryit.log";
for(my $i=0; $i<$countArgs; $i++) {
$WScript->Echo($arg->Item($i));
#print OUTPUT "$arg->Item($i)\n";
}
</script>
</job>
Call it "tryit.wsf" and run it with "tryit.wsf one two three" and it
puts up messages boxes with "one", "two" and "three" in them, as desired.
Now comment out the $WScript->Echo line and remove the comment on the
line below it; I expect this to write "one", "two" and "three" to the
log file. Instead when I run "tryit.wsf one two three" I get the
following log file:
Win32::OLE=HASH(0x179cea0)->Item(0)
Win32::OLE=HASH(0x179cea0)->Item(1)
Win32::OLE=HASH(0x179cea0)->Item(2)
Can anyone help me find out why replacing this "Echo" thing with a print
statement apparently changes the data printed? I'm mystified.