in reply to problems with truncate function

What are i am doing wrong?

You're typing "||" when you should be using "or"

Common Perl Pitfalls / perltrap , "or die" versus "|| die", and two more To || or not to or and why., Perl Idioms Explained - && and || "Short Circuit" operators, || die or or die :)

  • Comment on Re: problems with truncate function (perloperator precedence or ||)

Replies are listed 'Best First'.
Re^2: problems with truncate function (deparse)
by Anonymous Monk on Jun 26, 2013 at 08:09 UTC
      Hi, You are correct :-)
      I ran the perl with the B::Deparse module
      Perl parses the line
      truncate $fh,0 || die "could not truncate $dcs_log_file: $!";
      to
      truncate $fh, die("could not truncate ${log_file}: $!");
      Now i also understand the difference between || and or :-)

      In || it makes 0|| before truncate.
      with or it would make the truncate before

      Thanks,
      David

        See also the precedence table in perlop.

        --MidLifeXis