I have a header with this Parital code:
print start_html(
...
-script => [{-type=>"text/javascript", -src=>"/p
+ath/file1.js"}, {-type=>"text/javascript", -src => "path/file2.js"},
+{-type=>"text/javascript", -src => "$_js_path"}, {-code=> "$jscript"}
+],
...
That works. Now, if I need a certain page to load another file, I figured I could do this instead:
if($otherBlocksOfCode[0]) {# Already created...
# push the file1.js to this array...
push(@otherBlocksOfCode, {-type=>"text/javascript", -src=>"/path/file1
+.js"});
} else { # No other page created it, so create it now...
my @otherBlocksOfCode;
push(@otherBlocksOfCode, {-type=>"text/javascript", -src=>"/path/file1
+.js"});
}
print start_html(
...
-script => [@otherBlocksOfCode, {-type=>"text/ja
+vascript", -src => "path/file2.js"}, {-type=>"text/javascript", -src
+=> "$_js_path"}, {-code=> "$jscript"}],
...
But that did not work.
How can I dynamically add more scripts if other pages need more in the header?
Thanks.
Richard
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.