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");
};

dkochenourAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pratap_rCommented:
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,
Pratap
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.