perl如何內嵌html

來源:互聯網
上載者:User

   問:我現在有一個html的網頁代碼,要將其改為perl程式,如果只是單純在其第一行加上"#!../perl/bin/perl",並將檔案尾碼名改為.cgi,會出現錯誤提示"You don't have permission to access /test/index.cgi on this server."。換句話說:尾碼名為.cgi的perl裡如何包含html代碼?

  答:sub html_html

  {

  print "Content-type: text/html ";

  print <#這裡輸出html

  eof

  exit;

  }

  問:加了以後果然可以,但裡面的圖片"resource/Top.gif"卻不能顯示,圖片路徑絕對是正確的,如:resource/top.gif

  答:用相對路徑,最好做一個安裝檔案setup.cgi

  在你的這個檔案中:

  require "setup.cgi";

  然後這樣調用:lt;img src="$gif/top.gif">

  setup.cgi檔案中有這一行:

  $gif='http://your url/resource'; #圖片的URL路徑,注意是單引號而不是雙引號。

  這樣用相對路徑應該可以了。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.