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"}], ...