in reply to header - javascript

I figured it out... instead of doing a push... the way I was doing it:
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"}], ...
I just added it this way:
@_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/fi +le1.js"}); } else { @_extraJSCode = ({-type=>"text/javascript", -src=>"/jsfiles/st +_utilities.js"}); }
and that did work.

so it is resolved.

Richard

Replies are listed 'Best First'.
Re^2: header - javascript
by MidLifeXis (Monsignor) on Jul 29, 2013 at 13:09 UTC

    } else { # No other page created it, so create it now... my @otherBlocksOfCode; # <===== lexically scoped to else block push(@otherBlocksOfCode, {-type=>"text/javascript", -src=>"/path/file1 +.js"}); }
    Your else block is the containing block for the my @otherBlocksOfCode;. When the else is completed, that variable no longer exists. In other words, if you remove the my @otherBlocksOfCode; line, it should work how you expect.

    --MidLifeXis