am getting syntax error, can someone please explain how to insert a hyperlink into a table.
Syntax Error caused by Inserting Hyperlink in String
Collapse
X
-
Tags: None
-
Sorry about the poor topic but it is a perl question
part of my code consists of
<td><<A HREF="http://www.whatever.co m">http://www.whatever.co m</A></td>
And the error i get is "syntax error at line 99, near "<td><<A HREF="http""Comment
-
Haven't posted the whole code because most of it is HTML
but the code concerning the error is below
print "<table border='1'>";
print "<tr><td>Ty pe</td><td>Size</td><td>Price</td></tr>";
foreach $line (@all) {
chop($line);
($size,$price,$ type=split(/\|/,$line);
print "
<tr>
<td>$type</td>
<td>$size</td>
<td>$price</td>
<td><A HREF="http://www.whatever.co m">http://www.whatever.co m</A></td>
</tr>";
}
print"</table>";
If needed i could post the entire code
Also could you help me change some of the table attributes such as font, font colours, bgcolor, row width, column width
Thank youComment
-
you can't use unescaped double-quotes in a print command that uses double-quotes as the string terminator, add a backslash to escape embedded double-quotes:
perl has quote operators that make life easier:Code:print " <tr> <td>$type</td> <td>$size</td> <td>$price</td> <td><A HREF=\"http://www.whatever.com\">http://www.whatever.com</A></td> </tr>"; }
perldoc Quote and Quote like Operators
Comment
-
To fix your problem, either escape the double quotes inside the string, or use a different encloser. My personal preference is to use qq{my string here}.
Code:print qq{<table border='1'>}; print qq{<tr><td>Type</td><td>Size</td><td>Price</td></tr>}; foreach $line (@all) { chop($line); ($size, $price, $type) = split(/\|/, $line); print qq{ <tr> <td>$type</td> <td>$size</td> <td>$price</td> <td><A HREF="http://www.whatever.com">http://www.whatever.com</A></td> </tr>}; } print qq{</table>};Comment
-
Thanks for the help
It works nicely
But any ideas on improving how the table looks (fonts, colors etc.)
Thank YouComment
-
Another questionCode:print "<table border='1'>"; print "<tr><td>Type</td><td>Size</td><td>Price</td></tr>"; foreach $line (@all) { chop($line); ($size,$price,$type=split(/\|/,$line); print " <tr> <td>$type</td> <td>$size</td> <td>$price</td> <td><A HREF="http://www.whatever.com">http://www.whatever.com</A></td> </tr>"; } print"</table>";
The variable $type, how do i transfer that variable to another perl script using the hyperlink?
Most tutorials i have seen comment on forms but not hyperlinks
An suggestions
Thank YouComment
-
-
This code works nicely
I have used http://www.whatever.co m/cgi-bin/yourscript.pl?$ type
But what if i wish to transfer more than one variable using this method, is it possible?
For example tranfer $type, and $size, $code
Thank YouComment
Comment