开发者

How do I create a link on an image in a CGI script?

I can successfully show image in my CGI scripts via CGI.pm, using this code:

#!/usr/bin/perl -w
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard/;
print img {src => "../images/myimage.png", align=>"CENTER"};

However when I want to do is to include URL in that image, wo that whenever people click on that image it will point to the desired url, this code failed:

print img {src => "../images/myimage.png", align=>"CENTER", -href=>"www.google.com"};

What'开发者_如何学JAVAs the right way to do it?


#!/usr/bin/perl -w
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard/;
print a( { href => 'http://www.google.com' }, img {src => "../images/myimage.png", align=>"CENTER" } );

# OUTPUT:
<a href="http://www.google.com"><img align="CENTER" src="../images/myimage.png" /></a>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜