Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

weird behaviour of "print" 1

Status
Not open for further replies.

Graziella

Programmer
Jul 8, 2004
38
AT

Hi,

if $q = "How far from the earth is the sun?"
and I want to print $q in between <HELLO> and </HELLO>,
using simply the line
print "<HELLO> $q </HELLO>\n";

Why would the output be:
</HELLO>ow far from the earth is the sun?
With the second </HELLO> printed first, and the first character of the $q missing ?!

I have been moving the print line around the code, thinking that there might have a character before that conflicts with the print line, but nothing is working.
It is really weird. Never seen this before.

Grazia
 
if you can, test your script from the command prompt and see what it prints. If it still prints weird than I would have to assume the $q is getting redefined somewhere in the script before the print line. If not, it could be a browser issue, try testing the code in another browser and see what prints.

I know that I was confused recently with a chop problem out putting the results to Mozilla 1.5:

Code:
my $line = '{<x,2>,<y,-3>,<z,75>}';
chop($line);
print "$line\n";
# prints : {<x,2>,<y,-3>,<z,75> (as expected)
chop($line);
print $line;
# prints : {<x,2>,<y,-3>, (not as expected!)

I don't know why but Mozilla just will not print the chop results correctly on the second chop, not even in the source code.
 
Is the star an indication that something I posted helped solve your question? If so, can you post what the "problem" was please? [wink]
 
It's should work.

Do you run you script from command line or from a web browser ? For me, it's working on both.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top