Perl chomp sets reults 0 to 1

this perl script was running fine and all of a sudden it would return an error but the DTS package actually ran...Found out the chomp($results) was changing the value of 0 to 1...but why and all of a sudden?

## pipe stdio to log file
open (STDOUT, "| tee $logfile");
open (STDERR, "| tee $logfile");

## do not buffer STDOUT results
select (STDOUT);
$| = 1;

print "$script is starting\n";
print "Time now = ".FormatTimeDate()."\n";
print "Executing in $development\n";

## change directory
chdir ("$ecsjobs/$jobfolder") || die("Cannot change directory to $ecsjobs/$jobfolder");

print "Executing DTS package $package on $server\n";
$sql = "exec RunDTSPackage $package";

$cmd = "isql -S$server -U$uid -P$pwd -n -b -d$db -Q\"$sql\" ";
print  "isql -S$server -U$uid -n -b -d$db -Q\"$sql\" ";
$results = `$cmd`;
print "$results\n"; *** Here $results = 0
$error = $?;
print "$error\n";
$results = chomp($results);
print "$results\n"; **** here results = 1
if ( ($error != 0) or ($results =~ /Msg/) or ($results =~ /DB-LIBRARY error/) or ($results != 0) ) {
     die ("\n!!! Error DTSing data to USCLWAPGP01\PRODCOD !!!\n");

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

pratap_rConnect With a Mentor Commented:
hey dkochenour,

chomp returns a 0 when there is no \n character at the end. it returns a 1 if there is a \n at the end and is chomp(ed) off..

so you should be actually doing
chomp($results); # and not $results=chomp($results);

Have fun,
All Courses

From novice to tech pro — start learning today.