<div dir="ltr">Catalyst applications are Perl applications just like anyone else. If you want to access a hash variable (or any variable) which is declared (and possibly defined) in MyApp.pm (or any module for that matter), then all you need to do is refer to that variable from external sources (like templates) by its full name. So, for example, if the name of your variable is %HASH, then you can access it from your templates as %MyApp::HASH.<br>

<br>As a matter of fact, if when declaring the %HASH variable in MyApp.pm you do so by its full name, i.e. %MyApp::HASH, you don&#39;t even have to use &quot;my %HASH&quot; but just &quot;%MyApp::HASH&quot;. Not that it&#39;s any better, but anyway...<br>

<br>Ido.<br><br><div class="gmail_quote">On Wed, Mar 17, 2010 at 7:43 PM, Dermot <span dir="ltr">&lt;<a href="mailto:paikkos@googlemail.com">paikkos@googlemail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

Hi,<br>
<br>
I&#39;m sure there is a way but it&#39;s not jumping out at me.<br>
<br>
I have a list of countries and their associated database ID&#39;s that I<br>
need to stash in the header of (almost) every page on a site. I have<br>
no problems creating a controller that can do<br>
$c-&gt;model(DB::Countries)-&gt;search({foo=&gt;1}) and stick that into a<br>
$c-&gt;stash but I don&#39;t want to make repeated DB calls. I&#39;d like to<br>
create a hash at startup and make it available to<br>
root/lib/site/header. Is it possible to create a hash within<br>
lib/MyApp.pm that will be available throughout and how would my<br>
templates access it?<br>
<br>
TIA,<br>
Dp.<br>
<br>
_______________________________________________<br>
List: <a href="mailto:Catalyst@lists.scsys.co.uk">Catalyst@lists.scsys.co.uk</a><br>
Listinfo: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</a><br>
Searchable archive: <a href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/" target="_blank">http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</a><br>
Dev site: <a href="http://dev.catalyst.perl.org/" target="_blank">http://dev.catalyst.perl.org/</a><br>
</blockquote></div><br></div>