Newbie problems with > in a string

A

Albert Browne

I am using the code below in part of a subroutine. It displays ok later in
the routine within a <TEXTAREA> block.
But when I try to use $Meta elsewhere the string appears to be empty.
Further investigation shows the string is ok until it gets to the >
in the string. The string looks like this and does in the TEXTAREA
block<META NAME=\"AUTHOR\" CONTENT=\"AAA\"> which is correct.
I have tried printing the string a bit at a time it is ok until it gets to
the >. The string then appears to be empty. What am I missing?

Regards

Albert

$title = $query->param("Title");

if ($title ne "") {$Meta = "<META NAME=\"AUTHOR\" CONTENT=\"$title\">\n"} ;

$Owner = $query->param("Owner");

if ($Author ne "") {$Meta .= "<META NAME=\"AUTHOR\" CONTENT=\"$Owner\">\n"}
;
 
G

Gunnar Hjalmarsson

Albert said:
I am using the code below in part of a subroutine. It displays ok
later in the routine within a <TEXTAREA> block.
But when I try to use $Meta elsewhere the string appears to be
empty. Further investigation shows the string is ok until it gets
to the > in the string. The string looks like this and does in
the TEXTAREA block<META NAME=\"AUTHOR\" CONTENT=\"AAA\"> which is
correct.
I have tried printing the string a bit at a time it is ok until it
gets to the >. The string then appears to be empty. What am I
missing?

$Meta contains HTML code. When displaying HTML source code as CGI
output, it should better be encoded first. This is an easy way to do
that:

use HTML::Entities;
my $Meta_display = encode_entities($Meta);

See also the documentation of HTML::Entities:

http://www.perldoc.com/perl5.8.0/lib/HTML/Entities.html

It should be noted that your problem appears to be a CGI problem
rather than a Perl problem. A more appropriate group to discuss CGI is
comp.infosystems.www.authoring.cgi (ciwac).

If the above does not help, you'd better post to ciwac a small but
complete program that people can run and that illustrates the problem.
The code you posted here was confusing, and did not serve that
purpose.
 
L

LaDainian Tomlinson

:

$title = $query->param("Title");

if ($title ne "") {$Meta = "<META NAME=\"AUTHOR\" CONTENT=\"$title\">\n"} ;

$Owner = $query->param("Owner");

if ($Author ne "") {$Meta .= "<META NAME=\"AUTHOR\"
CONTENT=\"$Owner\">\n"};
^^^^^^^

Was that supposed to be $Owner? If you

use strict;

it'll warn you about those.

Brandan L.
 
L

LaDainian Tomlinson

:

CONTENT=\"$Owner\">\n"};
^^^^^^^

Yes, that's supposed to be pointing to $Author. I suppose that if you

use Shoddy::products qw/Microsoft/;

you can expect things to go wrong.

Brandan L.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,143
Messages
2,570,822
Members
47,368
Latest member
michaelsmithh

Latest Threads

Top