So it seems it’s OK to whack them in the main MyApp.pm , here is an example of what is currently in a ‘MemberGlobs.pm’, which is ‘required’ in 90% of all the perl scripts.
##########
# Yank Date #
##########
sub YankDate {
#_[0] = UK Date
# split to parts
my @dte = split(/\//, $_[0]);
# rebuild to yank date
my $yank = "$dte[2]-$dte[1]-$dte[0]";
# return result
$yank;
}
I’m forever having to switch between UK dates and USA dates so have helper
methods.
Where do these go?
Also where do you put application global constants?
Thanks,
Craig.
From: Dimitar Petrov [mailto:[email protected]]
Sent: 30 October 2012 13:52
To: The elegant MVC web framework
Subject: Re: [Catalyst] Global 'helper' methods
Hello Craig,
See the last answer. abraxxa describes it pretty well. Are those catalyst
specific? Probably provide an example so someone could provide a better
solution.
Cheers,
On Tue, Oct 30, 2012 at 2:03 PM, Craig Chant
<[email protected]<mailto:[email protected]>> wrote:
Hi,
Please could you advise the best way of having a global ‘helper’ class that has
all commonly used methods in it accessible for any part of the catalyst app.
I found this thread
http://stackoverflow.com/questions/11941836/catalyst-global-subroutines
With one indicating it’s ok to put them in the main MyApp.pm and another saying
to use Moose & Roles.
What is considered the correct way and could you provide an example of how I
create this helper class and bolt it to the Catalyst application.
Many thanks,
Craig Chant
I.T. Manager
[Description: cid:[email protected]]
Main Line 01903 602664
Direct Line 01903 227753
Visit our website http://www.homeloanpartnership.com
HomeLoan Partnership have been named the Best Mortgage Network, 2012, at the
myintroducer.com<http://myintroducer.com> Industry Awards
This Email and any attachments contain confidential information and is intended
solely for the individual to whom it is addressed. If this Email has been
misdirected, please notify the author as soon as possible. If you are not the
intended recipient you must not disclose, distribute, copy, print or rely on
any of the information contained, and all copies must be deleted immediately.
Whilst we take reasonable steps to try to identify any software viruses, any
attachments to this e-mail may nevertheless contain viruses, which our
anti-virus software has failed to identify. You should therefore carry out your
own anti-virus checks before opening any documents. HomeLoan Partnership will
not accept any liability for damage caused by computer viruses emanating from
any attachment or other document supplied with this e-mail. HomeLoan
Partnership reserves the right to monitor and archive all e-mail communications
through its network. No representative or employee of HomeLoan Partnership has
the authority to enter into any contract on behalf of HomeLoan Partnership by
email. HomeLoan Partnership is a trading name of H L Partnership Limited,
registered in England and Wales with Registration Number 5011722. Registered
office: 26-34 Old Street, London, EC1V 9QQ. H L Partnership Limited is
authorised and regulated by the Financial Services Authority.
_______________________________________________
List: [email protected]<mailto:[email protected]>
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/
This Email and any attachments contain confidential information and is intended
solely for the individual to whom it is addressed. If this Email has been
misdirected, please notify the author as soon as possible. If you are not the
intended recipient you must not disclose, distribute, copy, print or rely on
any of the information contained, and all copies must be deleted immediately.
Whilst we take reasonable steps to try to identify any software viruses, any
attachments to this e-mail may nevertheless contain viruses, which our
anti-virus software has failed to identify. You should therefore carry out your
own anti-virus checks before opening any documents. HomeLoan Partnership will
not accept any liability for damage caused by computer viruses emanating from
any attachment or other document supplied with this e-mail. HomeLoan
Partnership reserves the right to monitor and archive all e-mail communications
through its network. No representative or employee of HomeLoan Partnership has
the authority to enter into any contract on behalf of HomeLoan Partnership by
email. HomeLoan Partnership is a trading name of H L Partnership Limited,
registered in England and Wales with Registration Number 5011722. Registered
office: 26-34 Old Street, London, EC1V 9QQ. H L Partnership Limited is
authorised and regulated by the Financial Services Authority.
<<inline: image001.png>>
_______________________________________________ List: [email protected] Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
