<tt><font size=2>Put a subroutine in a separate place, where it can be
accessed / called, by<br>
whatever controllers need to use it?</font></tt>
<br><font size=2 face="sans-serif">-------------------------------------------------------------------------------------</font>
<br><font size=2 face="sans-serif">Why not put all your subroutines in
a Role &nbsp;and consume the role in your main application class.</font>
<br>
<br><font size=2 face="sans-serif">Package Role::HelpUtils;</font>
<br><font size=2 face="sans-serif">use Moose::Role;</font>
<br>
<br><font size=2 face="sans-serif">sub redirect_to_action {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; my ($c,
$controller, $action, @params) =@_;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; $c-&gt;response-&gt;redirect($c-&gt;uri_for($c-&gt;controller($controller)-&gt;action_for($action),
@params));</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; $c-&gt;detach;</font>
<br><font size=2 face="sans-serif">}</font>
<br>
<br><font size=2 face="sans-serif">1;</font>
<br>
<br><font size=2 face="sans-serif">In your main app class, simply use the
role</font>
<br><font size=2 face="sans-serif">package MyApp;</font>
<br><font size=2 face="sans-serif">use Moose; </font>
<br><font size=2 face="sans-serif">use Catalyst::Runtime ;</font>
<br><font size=2 face="sans-serif"><b>with 'Role::HelpUtils';</b></font>
<br>
<br><font size=2 face="sans-serif">You can then access the subroutines
using &nbsp;e.g $c-&gt;redirect_to_action()</font>
<br><font size=2 face="sans-serif"><br>
<br>
<br>
Thanks<br>
<br>
Tony B. Okusanya</font>
<br>
<br>
<br>
<br><font size=1 color=#5f5f5f face="sans-serif">From: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">&quot;Andrew&quot;
&lt;catalystgroup@unitedgames.co.uk&gt;</font>
<br><font size=1 color=#5f5f5f face="sans-serif">To: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">&quot;The elegant MVC
web framework&quot; &lt;catalyst@lists.scsys.co.uk&gt;, </font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">07/14/2016 05:59 PM</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Subject: &nbsp; &nbsp;
&nbsp; &nbsp;</font><font size=1 face="sans-serif">Re: [Catalyst]
KISS - Base Subroutines.</font>
<br>
<hr noshade>
<br>
<br>
<br><tt><font size=2>Okay, no worries, I've done it now.<br>
<br>
Created a folder called CommonUse to exist alongside Controller, View,
and<br>
Model folders, and hold perl modules that are commonly used, =).<br>
<br>
Create a file in the folder.<br>
<br>
Put my subroutine in the file.<br>
<br>
Then in the controller I want to find the subroutine, where it normally<br>
says:<br>
BEGIN { extends 'Catalyst::Controller' }<br>
...I switch it to say:<br>
BEGIN { extends 'MyApp::CommonUse::File' }<br>
....where MyApp is the name of my app, and File is the name of the perl<br>
module file I created in the CommonUse folder.<br>
Then that controller can call the subroutine, and everything seems to work,<br>
=).<br>
<br>
I read online, you could also put subrountines inside of Myapp.pm within
the<br>
lib folder, and all controllers could access it. I did try that, however,
I<br>
couldn't get it working, so any pointers on that appreciated.<br>
<br>
Yours,<br>
Andrew.<br>
<br>
<br>
<br>
----- Original Message -----<br>
From: &quot;Andrew&quot; &lt;catalystgroup@unitedgames.co.uk&gt;<br>
To: &quot;The elegant MVC web framework&quot; &lt;catalyst@lists.scsys.co.uk&gt;<br>
Sent: Thursday, July 14, 2016 9:20 PM<br>
Subject: [Catalyst] KISS - Base Subroutines.<br>
<br>
<br>
Is there a keep it simple stupid answer to the following question:<br>
<br>
Put a subroutine in a separate place, where it can be accessed / called,
by<br>
whatever controllers need to use it?<br>
<br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
List: Catalyst@lists.scsys.co.uk<br>
Listinfo: </font></tt><a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst"><tt><font size=2>http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</font></tt></a><tt><font size=2><br>
Searchable archive: </font></tt><a href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/"><tt><font size=2>http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</font></tt></a><tt><font size=2><br>
Dev site: </font></tt><a href=http://dev.catalyst.perl.org/><tt><font size=2>http://dev.catalyst.perl.org/</font></tt></a><tt><font size=2><br>
<br>
<br>
_______________________________________________<br>
List: Catalyst@lists.scsys.co.uk<br>
Listinfo: </font></tt><a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst"><tt><font size=2>http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</font></tt></a><tt><font size=2><br>
Searchable archive: </font></tt><a href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/"><tt><font size=2>http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</font></tt></a><tt><font size=2><br>
Dev site: </font></tt><a href=http://dev.catalyst.perl.org/><tt><font size=2>http://dev.catalyst.perl.org/</font></tt></a><tt><font size=2><br>
</font></tt>
<br><br><br>
U.S. BANCORP made the following annotations<br>---------------------------------------------------------------------<br>

<span style="font-family: Arial;" size="2;">Electronic Privacy Notice. This e-mail, and any attachments, contains information that is, or may be, covered by electronic communications privacy laws, and is also confidential and proprietary in nature. If you are not the intended recipient, please be advised that you are legally prohibited from retaining, using, copying, distributing, or otherwise disclosing this information in any manner. Instead, please reply to the sender that you have received this communication in error, and then immediately delete it. Thank you in advance for your cooperation.</span><br>
<br>
---------------------------------------------------------------------