Hi,

I need help regarding this script. This subroutine is supposeded to login into a database table ($TABLE) with query ($QUERY) and return the output. This is only a part of the total subroutine.


sub getEvents { my ($TABLE,$QUERY) = @_; my ($a, @T, $T, @keys, @fmt, @K, $k, $j, %event, @LIST); if ( open2(\*RDR, \*WTR, $NCO_SQL) ) { if ($QUERY) { print WTR "select * from $TABLE where $QUERY;\n"; } else { print WTR "select * from $TABLE;\n"; } print WTR "go\n"; print WTR "quit\n"; close WTR;

#while(<RDR>){print STDOUT "$_";}

       #$a .= $_ while(<RDR>);
       #print "\n======Break 1 \n$a======\n";

$a = <RDR>; chop ($a); #print $a;
do {
if ($a ne ' ') { $T = substr(join(':', split(/\s+/, $a)), 1); $keys[++$#keys] = $T; }
$a = <RDR>; #$a .= $_ while(<RDR>);chop $a; #print $a;
} until ( vec($a,0,8) != 9 );



1. Am I doing the right thing by $a = <RDR> to pass the value of <RDR> into $a? When I execute the script, I get the following error


substr outside of string at /opt/Omnibus/scripts/nco2perl line 58, <RDR> chunk 1.

line 58 is "if ($a ne ' ') { $T = substr(join(':', split(/\s+/, $a)), 1); $keys[++$#keys] = $T; }"

2. If I uncomment the section

                    $a .= $_ while(<RDR>);
                    print "\n======Break 1 \n$a======\n";

The right value of <RDR> is displayed. But if I try to print the value of $a in next section, it is empty.

Thanks
Rama

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail



-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to