Albert Browne wrote: > > 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"} ;
Hi Albert. I have to confess I don't really know what you mean. In particular, what do you mean by the string is ok until it gets to the > in the string ? Do you mean it's missing ">\n" off the end? Anyway, I have a few comments for you. Firstly, please put use strict; use warnings at the head of your program. This will help enormously with a lot of spurious problems. You will have to declare your variables with 'my', preferably as close as possible to the point of use. Secondly, if you're embedding double quotes in a string it's better to change the delimiter to avoid escaping the quotes. Thirdly, the test if ($Author ne "") is tidier written as if ($Author) Leaving us with the code below: use strict; use warnings; my $query; my $Meta; my $title = $query->param("Title"); $Meta = qq|<META NAME="AUTHOR" CONTENT="$title">\n| if $title; my $Author; my $Owner = $query->param("Owner"); # Should this be $Author? $Meta .= qq|<META NAME="AUTHOR" CONTENT="$Owner">\n| if $Author; You may well need to show us more of your code before we can give a proper answer. I hope this helps for now. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>