First, let's take a look at the -style attribute, which is used to include style sheets:
print $cgi->start_html(As you can see, it includes another hash, which would contain a name of src and a value of the style sheet you'd like included. This could extend on if there are multiple style sheets to include. The key difference you'll see when you run this version of our script is the addition of the <src> tag near the bottom:
-title => 'My CGI.pm Web Page',
-style => {
-src => '/css/main.css'
}
);
<link rel="stylesheet" type="text/css" href="/css/main.css" />Next we'll look at the -script attribute that can be used to include a javascript (or other) script file. Similar to the CSS -style attribute, -script is a has that includes the key / value pairs for -language and -src, with -src being the path to the file itself. Take a look at this example that includes the javascript file main.js:
print $cgi->start_html(This produces a nice <script> tag in the header:
-title => 'My CGI.pm Web Page',
-script => {
-language => 'javascript',
-src => '/javascript/main.js'
}
);
<script src="/javascript/main.js" type="text/javascript"></script>
