On Dec 19, 2007 2:05 PM, Tom Phoenix <[EMAIL PROTECTED]> wrote: > On 12/19/07, Chas. Owens <[EMAIL PROTECTED]> wrote: > > > On Dec 19, 2007 2:29 AM, Ravindra Ugaji <[EMAIL PROTECTED]> wrote: > > > > chdir ( '/opt/application') || die ("Can't change directory: $!\n"); > > > tried this also > > > chdir "/opt/application" || die "Can't change directory: $!\n"; > > > In addition to what others have already said, never do the second*. > > The || operator has a higher precedence than function calls, so > > > > func "string" || die "oops"; > > > > is really saying > > > > func("string" || die("oops")); > > > > Since "string" is truthy, the die will never occur. > > You have the right idea about functions in general; but chdir() is a > "named unary operator", so it has higher precedence than the || > operator: > > chdir "/any/wrong/path" || die "This will indeed die: $!"; > > That means that the OP's code isn't so wrong as it may seem, even > though there's surely a better way to write it. snip
That is the reason I used func instead of chdir. The "don't use || in that way, use or instead" is more of a general warning not to use the construct (because it will bite you). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/