List Info

Thread: CHOMP leaving whitespace




CHOMP leaving whitespace
country flaguser name
United States
2007-09-20 18:59:20

OK, I'm stumped. I have a very simple script that opens a text file
containing 1 item per line. It then reads the text file line by line
and acts on certain lines in a certain way.

The problem is simple, but it has me stumped. I am reading a line and
chomping it to remove the newline. The problem is that it is still
leaving a space even though there is none present in the text file.

Here is a sample code:

Text file:

1
something
2
something

Script:

$scalar = <TEXT&gt;;
chomp ($scalar);
if ($scalar == 1){
do something;
}

The problem is that when I compare the "1&quot; that I picked up from the
text file to 1 it is not giving a true result because I actually have
&quot;1 " in $scalar.

Now, this script worked fine when I was running it under Perl on my
own machine (Windows XP) but when I convert it to CGI and upload it to
my site (Apache run) I start having this problem. I can make it work
if I use CHOP but I know that I shouldn't have to do it that way.

I couldn't find anything that referred to this in my books or on the
web. I hope someone can help!

Thanks
Andy Schafer

__._,_.___
.

__,_._,___
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )