N
niall.macpherson
Sorry if the answer to this is obvious but I have been staring at this
for some time now and searched clpm for <DATA> without any further
enlightenment
The attached code may seem pointless but it is the smallest piece of
self contained code I could produce which replicates the problem I am
seeing in my real code.
When it is run as given it produces
$VAR1 = 'string1';
$VAR1 = 'string2';
which is precisely what I would expect.
However when I uncomment the #my $results = RunCommand(); line
I see the following
$VAR1 = 'string1';
$VAR1 = '';
$VAR1 = 'string2';
Can anyone please explain where the extra empty value comes from ? I am
running Active Perl 5.8.7 build 813 on Windoze XP
Thanks
use strict;
use warnings;
use Data:
umper;
##---------------------------------------------------------------------
sub RunCommand
{
my $cmd_string = 'dir';
my $output = '';
open(SQLPROC, "$cmd_string 2>NUL |");
while(<SQLPROC>)
{
$output .= $_;
}
close SQLPROC;
return($output);
}
##--------------------------------------------------------------------------------------
while(<DATA>)
{
chomp;
print Dumper $_;
#my $results = RunCommand();
#print Dumper $results;
}
__DATA__
string1
string2
for some time now and searched clpm for <DATA> without any further
enlightenment
The attached code may seem pointless but it is the smallest piece of
self contained code I could produce which replicates the problem I am
seeing in my real code.
When it is run as given it produces
$VAR1 = 'string1';
$VAR1 = 'string2';
which is precisely what I would expect.
However when I uncomment the #my $results = RunCommand(); line
I see the following
$VAR1 = 'string1';
$VAR1 = '';
$VAR1 = 'string2';
Can anyone please explain where the extra empty value comes from ? I am
running Active Perl 5.8.7 build 813 on Windoze XP
Thanks
use strict;
use warnings;
use Data:
##---------------------------------------------------------------------
sub RunCommand
{
my $cmd_string = 'dir';
my $output = '';
open(SQLPROC, "$cmd_string 2>NUL |");
while(<SQLPROC>)
{
$output .= $_;
}
close SQLPROC;
return($output);
}
##--------------------------------------------------------------------------------------
while(<DATA>)
{
chomp;
print Dumper $_;
#my $results = RunCommand();
#print Dumper $results;
}
__DATA__
string1
string2