[ale] Perl coding style

Watson, Keith krwatson at cc.gatech.edu
Fri Jan 18 10:06:35 EST 2013


In some cases the subroutine must be defined before you call it.

sub HELLO {

   my ($name) = shift @_;

   print ("Hello ", $name, "\n");

}


If you call the subroutine this way you have to define the subroutine before the call.

HELLO "Geoffrey";


However, if you call the subroutine this way you can define the subroutine before or after the call.

&HELLO("Geoffrey");


Perl Subroutine Primer
http://www.webreference.com/programming/perl/subroutines/index.html


As for Perl style I recommend Perl Best Practices by Damian Conway
http://www.amazon.com/Perl-Best-Practices-Damian-Conway/dp/0596001738


keith

-- 

Keith R. Watson                        Georgia Institute of Technology
IT Support Professional Lead           College of Computing
keith.watson at cc.gatech.edu             801 Atlantic Drive NW
(404) 385-7401                         Atlanta, GA 30332-0280


> -----Original Message-----
> From: ale-bounces at ale.org [mailto:ale-bounces at ale.org] On Behalf Of
> Geoffrey Myers
> Sent: Friday, January 18, 2013 09:42
> To: ALE run Linux!
> Subject: [ale] Perl coding style
> 
> I've noticed that most perl coders see to put subroutines before the main
> code.
> 
> Comments?
> 
> --
> From my iPhone
> Geoffrey Myers
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo



More information about the Ale mailing list