Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Perl chomp sets reults 0 to 1

Posted on 2004-10-29
Medium Priority
Last Modified: 2006-11-17
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");

Question by:dkochenour
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 11

Accepted Solution

pratap_r earned 2000 total points
ID: 12447717
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,

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Loops Section Overview

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question