On Thu, 2004-08-05 at 11:07, [EMAIL PROTECTED] wrote: > Hi All, Hi
> I am using code written by some one else. I didn't understand the difference > between these subroutines, the way they were defined. > > 1. sub addToLog { Some code } Any specific reason where we should > not use braces ?? > 2. sub displayEnv( ) { " } Any specific reason why we should > use braces ?? > 3. sub trim($) { " } Any specific reason why we should > use a brace with a $ sign in it ?? Those are prototypes. Basically, you use them to specify how your subroutine is to be treated. sub trim($), for instance, means that trim will work on a scalar. This is useful to, instead of something such as trim($var) use something such as trim $var Also, trim by itself is interpreted as trim($_) trim $var1, $var2 is the same as trim($var1), $var2 > sub displayEnv( ) { " } This makes displayEnv by itself (that is, with no braces) work in your code, not munching up anything following it :-) > Could some one specify reason when to use braces and when not to use . > Replies are highly appreciated and thanks in advance for your help. You're the one who has to choose, I guess :-) > Regards > Anand HTH, jac -- José Alves de Castro <[EMAIL PROTECTED]> http://natura.di.uminho.pt/~jac
signature.asc
Description: This is a digitally signed message part