Home  |  Linux  | Mysql  | PHP  | XML
From:Uri Guttman Date:Fri Sep  3 06:48:19 2010
Subject:Re: Traversing Hash printing two times
>>>>> "JG" == Jim Gibson <jimsgibson@gmail.com> writes:

JG> At 11:29 AM +0530 9/3/10, Jatin Davey wrote:
>> Any reason to use named variables than to use the default variable ($_) ?

JG> Two reasons that I know:

JG> 1. If you use a named variable, you and everybody else reading your
JG> code will know what it is for. While it doesn't matter much for 3-line
JG> loops, short programs tend to turn into longer ones, and then you
JG> really should be using named variables.

JG> 2. The default variable $_ can get clobbered by some operations. If
JG> you use $_, you have to be careful to avoid such operations. It is
JG> much better not to have to worry.

JG> Quiz for extra credit: Uri's program has a misleadingly-named
JG> variable. Can you figure out what it is?

and john pointed it out already so no cheating. a brainfart on my part.

uri

--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
Navigate in group perl.beginners at sever nntp.perl.org
Previous Next


Your recent visits
AW: Using common object, without passing it around
Re: Traversing Hash printing two times
Re: AW: friend class in perl
Re: floating point precision
Re: help on example from "mastering algorithm with perl" on binary search



  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.
Site Maintained by Zareef Ahmed
Powered By PHP Consultants