'my' being a lexical variable, has the most restrictive scope. It is 
visible only in the block and it also masks out  another variable of same 
name defined outside the block. 

However, here both equivalent. If you were only testing the hash

next unless $hash{$val}; 

should work equally well.




Richard Morse <[EMAIL PROTECTED]>

Sent by: [EMAIL PROTECTED]
11/13/2003 11:37 AM

 
        To:     Boston-Pm <[EMAIL PROTECTED]>
        cc: 
        Subject:        [Boston.pm] "next unless my"


Hi!  I'm writing a program, and I've reached a point where it makes (I 
think) to combine two lines into one.  The two original lines are 
something like:
                 my $var = $hash{$val};
                 next unless (defined($var));

I'm thinking that it might make more sense (given the flow of the 
program at this point which is a large variety of 'next unless' 
statements) to write:
                 next unless my $val = $hash{$val};

However, I recall at a previous Boston.pm meeting there being a 
discussion about issues with 'my' in conditional clauses.  I don't, 
however, remember the details.  Is this usage of 'my' the one that 
causes the problem?

Thanks,
Ricky Morse

_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm



_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to