Home  |  Linux  | Mysql  | PHP  | XML
From:Jim Gibson Date:Fri Sep  3 06:33:55 2010
Subject:Re: Traversing Hash printing two times
At 11:29 AM +0530 9/3/10, Jatin Davey wrote:

>Any reason to use named variables than to use the default variable ($_) ?

Two reasons that I know:

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

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

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

--
Jim Gibson
Jim@Gibson.org
Navigate in group perl.beginners at sever nntp.perl.org
Previous Next


Your recent visits
Re: AW: Using common object, without passing it around
HTML::Template, CGI::APP with the JSON + Jquery please help.
Re: script for shutdown remote machine
Re: help on example from "mastering algorithm with perl" on binarysearch
Re: floating point precision



  
© 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