in reply to Re: sql-o-matic
in thread sql-o-matic

my $dbh=DBI->connect($dsn,$opts{user}{value},$opts{password}{value +}) || die($!);
The || operator has higher precedence than the = operator so you should either enclose the assignment in parentheses or use the lower precedence or operator.

Wrong. As die($!) never returns, it doesn't matter which way you write it.

Replies are listed 'Best First'.
Re^3: sql-o-matic
by massa (Hermit) on Sep 16, 2008 at 16:26 UTC
    Sorry but, even if your phrase holds a truth value, you are wrong in many levels.
    1. die can be overriden in one way or another, and start returning something!
    2. my $c = 'shat'; eval { $c = DBI->connect(xxx) || die } keeps the old value in $c (instead of putting undef there, like or would do), and this may not be what the user wants...
    3. it would be nice if people grew accostumed not to mix = and || inadvertently.
    So, my $c = DBI->connect(xxx) or die is the right idiom for good reasons.
    []s, HTH, Massa (κς,πμ,πλ)