gube has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks,
I usually use the 'or' operator and zero value while assigning values to scalar, when i assign scalar varaible to scalar variable. (For Eg. my $var = $var1 || 0). So, if $var1 is empty the 0 will be assign to $var variable. In this subroutine also i did the same. But, in this case if i print "$price" the output i am getting is 8. Anyone please guide me. I can return 0,0 from the subroutine. By mistake i did 'or' opearator and assign zero value. I just wanted to know how the values assigning.
#!/usr/local/bin/perl use strict; use warnings; my ($price, $floor) = &get_price_floor() || 0; print $price; sub get_price_floor { return (10, 8); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: In What basis the subroutine return values assign to variables ?
by bart (Canon) on Jul 30, 2007 at 10:40 UTC | |
Re: In What basis the subroutine return values assign to variables ?
by FunkyMonk (Chancellor) on Jul 30, 2007 at 10:38 UTC | |
Re: In What basis the subroutine return values assign to variables ?
by Anno (Deacon) on Jul 30, 2007 at 10:45 UTC | |
Re: In What basis the subroutine return values assign to variables ?
by gube (Parson) on Jul 30, 2007 at 11:39 UTC |
Back to
Seekers of Perl Wisdom