From: Paul Brannan Date: 2007-09-18T23:50:13+09:00 Subject: Re: scope questions On Tue, Sep 18, 2007 at 11:29:25PM +0900, Mister Rohit wrote: > my $var=1; > { > my $var=2; > print "inner=$var\n" > } > print "outer=$var\n" If the variables really are different, then use a different variable name. Even though you can do this in perl, that does not make it a good idea. Methods should, in general, be short enough that you do not have naming conflicts between local variables. If you find yourself running into this a lot, you are probably doing too much in one method, which can make code harder to read and to refactor later on. Matz has discussed some syntaxes for what you want for Ruby 2.0, such as: var = 1 local { |var| var = 2 } puts var #=> 1 (so that block parameters are always local to the block) but I don't know what the current status of this is. Paul