mpalmer12345
Programmer
Same program - 2 different results!
I am puzzled why I am getting two different results with the exact same program! The only difference is that one is being run on my home computer and the other is on the Web.
$text = '<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<div align="center">
<table width="47%" border="0" align="center">
<tr>
<td width="16%">
<div align="right"><b><font><i>URL</i></font></b></div>
';
$text =~ s/\n/g;
my $txxx = "";
my $flag = 1;
while ($flag < 3) {
print "$txxx\n";
print "xxxxxxxxxxxxxxxxxxxx\n";
$flag += 1;
$text =~ s/<(.+?)>(.*)/$2/g;
$txxx .= "<$1>";
}
$text = $txxx;
print "$text\n";
#
The program on my computer gives
xxxxxxxxxxxxxxxxxxxx
<html>
xxxxxxxxxxxxxxxxxxxx
<html><head>
which is what I want.
But the program though CGI and this added code at the top
#!/usr/bin/perl
use LWP::Simple;
use CGI;
my $cgi = new CGI;
my $url = $cgi->param("urlval");
my $text = get($url);
print "Content-type: text/html\n\n";
gives
xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx
I am pretty sure the command
$text =~ s/\n//g;
is the source of the problem since when I take it out the result is a match -- but it's not the right results. I don't know how else to remove the line breaks from the original text that would make the problem go away.
I am puzzled why I am getting two different results with the exact same program! The only difference is that one is being run on my home computer and the other is on the Web.
$text = '<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<div align="center">
<table width="47%" border="0" align="center">
<tr>
<td width="16%">
<div align="right"><b><font><i>URL</i></font></b></div>
';
$text =~ s/\n/g;
my $txxx = "";
my $flag = 1;
while ($flag < 3) {
print "$txxx\n";
print "xxxxxxxxxxxxxxxxxxxx\n";
$flag += 1;
$text =~ s/<(.+?)>(.*)/$2/g;
$txxx .= "<$1>";
}
$text = $txxx;
print "$text\n";
#
The program on my computer gives
xxxxxxxxxxxxxxxxxxxx
<html>
xxxxxxxxxxxxxxxxxxxx
<html><head>
which is what I want.
But the program though CGI and this added code at the top
#!/usr/bin/perl
use LWP::Simple;
use CGI;
my $cgi = new CGI;
my $url = $cgi->param("urlval");
my $text = get($url);
print "Content-type: text/html\n\n";
gives
xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx
I am pretty sure the command
$text =~ s/\n//g;
is the source of the problem since when I take it out the result is a match -- but it's not the right results. I don't know how else to remove the line breaks from the original text that would make the problem go away.