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/javascript", -src => "path/file2.js"}, {-type=>"text/javascript", -src => "$_js_path"}, {-code=> "$jscript"}], ... #### @_extraJSCode = ({-type=>"text/javascript", -src=>"http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"},); # then at the main header, where it is built, I do this: if($_extraJSCode[0]) { push(@_extraJSCode, {-type=>"text/javascript", -src=>"/path/file1.js"}); } else { @_extraJSCode = ({-type=>"text/javascript", -src=>"/jsfiles/st_utilities.js"}); }