Link to home
Start Free TrialLog in
Avatar of lonelyplanet
lonelyplanet

asked on

Why perl program output this ?

Hi,

I've written below perl program for testing in my web site hosted in one ISP.

Source code below:

#!/usr/bin/perl

$a = "Hello!";
print "Content-type: text/html\n\n";
print "<html>\n<head>\n";
print "</head>\n<body>\n";

$e = "<xxxx>";
$e =~ s/<//;
print "variable e = $e<br>";
$e =~ s/>//;
print "variable e = $e<br>";

$f = "<xxxx>";
$f =~ s/>//;
print "variable f = $f<br>";
$f =~ s/<//;
print "variable f = $f<br>";

print "</body>\n</html>";

Output of the program at browser is as follow:

variable e = xxxx>
variable e = xxxx
variable f = variable f = xxxx

Why will 2 distnct print statements for $f will result in only one output line ? Why the second print statement seems overwriting the first ? Is there any meaning to character '<' if it appears alone in a " " quoted string i.e. "<xxxx" ?

ASKER CERTIFIED SOLUTION
Avatar of rj2
rj2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Nothing has happened on this question in over 2 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
split points between rj2 [100 ptt] and jhurst [25 pts].

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer