I'm writting Perl/CGI script with the module CGI.pm. I can return text/html, but can't include an image within it, it always display the 'alt' tag and I'm sure about the href link.
Here's my code :
#!/usr/bin/perl -w
use strict;
use CGI;
my $cgi = new CGI;
print $cgi->header(-type=>'text/html'),
      $cgi->start_html(-title=>'Test Page'),
      $cgi->h1('Infos switch'),
     开发者_运维百科   "This is a test.",
      $cgi->h1('Testing'), $cgi->hr, "\n",
      $cgi->img(-src=>'http://www.perl.org/simages/lcamel.gif',  
                -alt=>'Powered by Perl'), "\n\n",
      $cgi->end_html;
exit;
First, you're not getting the alt text. You're sending <img>-src http://www.perl.org/simages/lcamel.gif -alt Powered by Perl, so the image doesn't even have alt text.
The first argument of img should be a hash of attributes. The rest is taken as child elements.
$cgi->img({
   -src => 'http://www.perl.org/simages/lcamel.gif',  
   -alt => 'Powered by Perl',
})
The dashes are optional, so you could also use
$cgi->img({
   src => 'http://www.perl.org/simages/lcamel.gif',  
   alt => 'Powered by Perl',
})
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论