Re: Early adopters of symbol based dependencies needed
On Wed, 21 Nov 2007, Russ Allbery wrote:
> Be careful about && because you can get the opposite problem.
>
> exists $self->{flags}{DYNAMIC && $self->{flags}{DYNAMIC}
>
> will be parsed as
>
> exists ($self->{flags}{DYNAMIC && $self->{flags}{DYNAMIC})
>
> It's often good style to always use parens with the argument to defined or
> exists because they're most often the functions that get bitten by this.
Aren't they supposed to have a prototype to avoid such behaviour?
I mean exists should behave like myprint2 in the example below:
sub myprint {
print $_[0] . "\n";
}
sub myprint2 ($) {
print $_[0] . "\n";
}
%a = ('a' => 'this is a');
myprint $a{a} && exists $a{a};
myprint2 $a{a} && exists $a{a};
Cheers,
--
Raphaël Hertzog
Premier livre français sur Debian GNU/Linux :
http://www.ouaza.com/livre/admin-debian/
Reply to: