Re: & and subroutine

2012-04-19 Thread Paul.G
Thanks for everyone's assistance, I think I have my answer. I will be looking closer at the comments. cheers From: Michael Rasmussen To: beginners@perl.org Sent: Tuesday, 17 April 2012 11:01 PM Subject: Re: & and subroutine And for what it

Re: & and subroutine

2012-04-17 Thread Uri Guttman
On 04/17/2012 08:30 AM, Manfred Lotz wrote: On Tue, 17 Apr 2012 12:27:32 +0100 Gary Stainburn wrote: On Monday 16 April 2012 15:20:35 Paul Johnson wrote: On Mon, Apr 16, 2012 at 06:53:53AM -0700, Paul.G wrote: Hi All Have a question, is it good coding practice to use a& when calling a subr

Re: & and subroutine

2012-04-17 Thread Uri Guttman
On 04/17/2012 07:03 AM, 'lesleyb' wrote: On Mon, Apr 16, 2012 at 04:20:35PM +0200, Paul Johnson wrote: On Mon, Apr 16, 2012 at 06:53:53AM -0700, Paul.G wrote: Hi All Have a question, is it good coding practice to use a& when calling a subroutine, or it is not required, or it doesn't matter?

Re: & and subroutine

2012-04-17 Thread Ken Slater
On Tue, Apr 17, 2012 at 9:43 AM, Gary Stainburn wrote: > On Tuesday 17 April 2012 13:30:59 Manfred Lotz wrote: >> >> One example is this: >> >> #! /usr/bin/perl >> >> use strict; >> use warnings; >> >> mysub; >> >> sub mysub { >>   print "Hi there\n"; >> } >> >> If you run this you get an error: >

Re: & and subroutine

2012-04-17 Thread Gary Stainburn
On Tuesday 17 April 2012 15:13:40 Manfred Lotz wrote: > You have > sub mysub() { > > instead of > > sub mysub { > > which is the correct way. Thank you. I can't believe how many years I've been getting that one wrong. Gary -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional

Re: & and subroutine

2012-04-17 Thread Manfred Lotz
On Tue, 17 Apr 2012 14:43:01 +0100 Gary Stainburn wrote: > On Tuesday 17 April 2012 13:30:59 Manfred Lotz wrote: > > > > One example is this: > > > > #! /usr/bin/perl > > > > use strict; > > use warnings; > > > > mysub; > > > > sub mysub { > > print "Hi there\n"; > > } > > > > If you run this y

Re: & and subroutine

2012-04-17 Thread Gary Stainburn
On Tuesday 17 April 2012 13:30:59 Manfred Lotz wrote: > > One example is this: > > #! /usr/bin/perl > > use strict; > use warnings; > > mysub; > > sub mysub { > print "Hi there\n"; > } > > If you run this you get an error: > Bareword "mysub" not allowed while "strict subs" in use at ./testsub.pl

Re: & and subroutine

2012-04-17 Thread Michael Rasmussen
And for what it's worth. 113. Call subroutines with parentheses but without a leading & That's from Damian Conway's Perl Best Practices A quick reference to the 256 guidelines is found at http://refcards.com/docs/vromansj/perl-best-practices/refguide.pdf And a bit of luck, the entire chapter on s

Re: & and subroutine

2012-04-17 Thread Michael Rasmussen
On Tue, Apr 17, 2012 at 02:30:59PM +0200, Manfred Lotz wrote: > > Could someone please expand on this as I seem to always have to do > > this. If I 'use strict' and 'use warnings' I get errors if I don't. > > > > One example is this: > > #! /usr/bin/perl > > use strict; > use warnings; > > mys

Re: & and subroutine

2012-04-17 Thread Shawn H Corey
On 12-04-17 08:30 AM, Manfred Lotz wrote: On Tue, 17 Apr 2012 12:27:32 +0100 Gary Stainburn wrote: > On Monday 16 April 2012 15:20:35 Paul Johnson wrote: > > On Mon, Apr 16, 2012 at 06:53:53AM -0700, Paul.G wrote: > > > Hi All > > > > > > Have a question, is it good coding practic

Re: & and subroutine

2012-04-17 Thread Manfred Lotz
On Tue, 17 Apr 2012 12:27:32 +0100 Gary Stainburn wrote: > On Monday 16 April 2012 15:20:35 Paul Johnson wrote: > > On Mon, Apr 16, 2012 at 06:53:53AM -0700, Paul.G wrote: > > > Hi All > > > > > > Have a question, is it good coding practice to use a & when > > > calling a subroutine, or it is not

Re: & and subroutine

2012-04-17 Thread Gary Stainburn
On Monday 16 April 2012 15:20:35 Paul Johnson wrote: > On Mon, Apr 16, 2012 at 06:53:53AM -0700, Paul.G wrote: > > Hi All > > > > Have a question, is it good coding practice to use a & when calling a > > subroutine, or it is not required, or it doesn't matter? > > It's good practice not to use it u

Re: & and subroutine

2012-04-17 Thread 'lesleyb'
On Mon, Apr 16, 2012 at 04:20:35PM +0200, Paul Johnson wrote: > On Mon, Apr 16, 2012 at 06:53:53AM -0700, Paul.G wrote: > > Hi All > > > > Have a question, is it good coding practice to use a & when calling a > > subroutine, or it is not required, or it doesn't matter? > > It's good practice not

Re: & and subroutine

2012-04-16 Thread Paul Johnson
On Mon, Apr 16, 2012 at 06:53:53AM -0700, Paul.G wrote: > Hi All > > Have a question, is it good coding practice to use a & when calling a > subroutine, or it is not required, or it doesn't matter? It's good practice not to use it unless you understand exactly why you would need to use it. --