I think the question is pretty self explanitory, but I'm using perl to generate a webpage. Starts off using:
$cgi->start_html(-title=>'myPage',-style=>{-src=>'style.css'}, -script=>{-type=>'JAVASCRIPT', -src=>'custom.js'}, );
List item
But what if I want to have multiple scripts in the the header? Or Multiple CSS style sheets?
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript" src="custom.js"></script>
<link rel="stylesheet" href="css/basic.css" type="text/css" />
<link rel="stylesheet" href="css/style.css" type="text/css" />
Use anonymous array:
$cgi->start_html(
-title=>'myPage',
-style=>[{-src=>'style.css'},{-src=>'basic.css'}],
-script=>[{-type=>'JAVASCRIPT', -src=>'custom.js'},{-type=>'JAVASCRIPT', -src=>'http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js'}],
);
Of course. When you think more than one, think array. When you think passing arrays as arguments, think array ref.
use warnings;
use strict;
use CGI qw(:standard);
print start_html(-title => "myPage",
-style => [ {-src=>"style.css"},
{-src=>"basic.css"}, ],
-script => [ {-type=>"text/javascript",
-src=>"custom.js"},
{-type=>"text/javascript",
-src=>"ohai.js"}, ], );
__END__
…snip…
<title>myPage</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="stylesheet" type="text/css" href="basic.css" />
<script src="custom.js" type="text/javascript"></script>
<script src="ohai.js" type="text/javascript"></script>
…snip…
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With