mpalmer12345
Programmer
I am having a devil of a time figuring this out!
I am taking as my data the source code brought in from a website via LWP::Simple, such as the following:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.61 [en]C-compaq (Win98; U) [Netscape]">
<meta name="Author" content="AS">
<title>Contents</title>
</head>
I then want to write a bit of code that removes the newlines between HTML and HEAD etc. so that it comes out as
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.61 [en]C-compaq (Win98; U) [Netscape]">
<meta name="Author" content="AS">
<title>Contents</title></head>
I am using
$text =~ s/>\n+?</></ig;
which works well on my Perl program at home (I am using Mac), but when I test it out on the identical code on the webpage, it doesn't remove the newlines! Why isn't it doing on the webpage what it does at home???
I am taking as my data the source code brought in from a website via LWP::Simple, such as the following:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.61 [en]C-compaq (Win98; U) [Netscape]">
<meta name="Author" content="AS">
<title>Contents</title>
</head>
I then want to write a bit of code that removes the newlines between HTML and HEAD etc. so that it comes out as
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.61 [en]C-compaq (Win98; U) [Netscape]">
<meta name="Author" content="AS">
<title>Contents</title></head>
I am using
$text =~ s/>\n+?</></ig;
which works well on my Perl program at home (I am using Mac), but when I test it out on the identical code on the webpage, it doesn't remove the newlines! Why isn't it doing on the webpage what it does at home???