<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META content="MSHTML 5.50.4807.2300" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>Thanks for&nbsp;your suggestion, Tony, =).</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>In your example, is HelpUtils a .pm file?</FONT></DIV>
<DIV><FONT size=2>And if so, where in the Catalyst folder structure would it be 
placed?</FONT></DIV>
<DIV><FONT size=2>Would I need to create a folder called Role? </FONT></DIV>
<BLOCKQUOTE 
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV 
  style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
  <A title=anthony.okusanya@usbank.com 
  href="mailto:anthony.okusanya@usbank.com">anthony.okusanya@usbank.com</A> 
  </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A title=catalyst@lists.scsys.co.uk 
  href="mailto:catalyst@lists.scsys.co.uk">The elegant MVC web framework</A> 
  </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> Friday, July 15, 2016 12:46 
AM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [Catalyst] KISS - Base 
  Subroutines.</DIV>
  <DIV><BR></DIV><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 face=sans-serif 
  size=2>-------------------------------------------------------------------------------------</FONT> 
  <BR><FONT face=sans-serif size=2>Why not put all your subroutines in a Role 
  &nbsp;and consume the role in your main application class.</FONT> 
  <BR><BR><FONT face=sans-serif size=2>Package Role::HelpUtils;</FONT> <BR><FONT 
  face=sans-serif size=2>use Moose::Role;</FONT> <BR><BR><FONT face=sans-serif 
  size=2>sub redirect_to_action {</FONT> <BR><FONT face=sans-serif size=2>&nbsp; 
  &nbsp; &nbsp; &nbsp; my ($c, $controller, $action, @params) =@_;</FONT> 
  <BR><FONT face=sans-serif size=2>&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 face=sans-serif size=2>&nbsp; &nbsp; &nbsp; &nbsp; 
  $c-&gt;detach;</FONT> <BR><FONT face=sans-serif size=2>}</FONT> <BR><BR><FONT 
  face=sans-serif size=2>1;</FONT> <BR><BR><FONT face=sans-serif size=2>In your 
  main app class, simply use the role</FONT> <BR><FONT face=sans-serif 
  size=2>package MyApp;</FONT> <BR><FONT face=sans-serif size=2>use Moose; 
  </FONT><BR><FONT face=sans-serif size=2>use Catalyst::Runtime ;</FONT> 
  <BR><FONT face=sans-serif size=2><B>with 'Role::HelpUtils';</B></FONT> 
  <BR><BR><FONT face=sans-serif size=2>You can then access the subroutines using 
  &nbsp;e.g $c-&gt;redirect_to_action()</FONT> <BR><FONT face=sans-serif 
  size=2><BR><BR><BR>Thanks<BR><BR>Tony B. Okusanya</FONT> <BR><BR><BR><BR><FONT 
  face=sans-serif color=#5f5f5f size=1>From: &nbsp; &nbsp; &nbsp; 
  &nbsp;</FONT><FONT face=sans-serif size=1>"Andrew" 
  &lt;catalystgroup@unitedgames.co.uk&gt;</FONT> <BR><FONT face=sans-serif 
  color=#5f5f5f size=1>To: &nbsp; &nbsp; &nbsp; &nbsp;</FONT><FONT 
  face=sans-serif size=1>"The elegant MVC web framework" 
  &lt;catalyst@lists.scsys.co.uk&gt;, </FONT><BR><FONT face=sans-serif 
  color=#5f5f5f size=1>Date: &nbsp; &nbsp; &nbsp; &nbsp;</FONT><FONT 
  face=sans-serif size=1>07/14/2016 05:59 PM</FONT> <BR><FONT face=sans-serif 
  color=#5f5f5f size=1>Subject: &nbsp; &nbsp; &nbsp; &nbsp;</FONT><FONT 
  face=sans-serif size=1>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: "Andrew" 
  &lt;catalystgroup@unitedgames.co.uk&gt;<BR>To: "The elegant MVC web framework" 
  &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>---------------------------------------------------------------------
  <P>
  <HR>

  <P></P>_______________________________________________<BR>List: 
  Catalyst@lists.scsys.co.uk<BR>Listinfo: 
  http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst<BR>Searchable 
  archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/<BR>Dev site: 
  http://dev.catalyst.perl.org/<BR></BLOCKQUOTE></BODY></HTML>