in reply to Re: perlcritic compliant way to eval?
in thread perlcritic compliant way to eval?

Hauke D

Thanks for the info. Using 'do' like that had fallen off my knowledge stack. It seemed to work at first for me but is acting wonky, so I'll have to look at it more as well as your other post. Particularly for future use.

As for bypassing the lint checks, I'll admit, I do have a few coding style quirks of my own. I cuddle my elses and line up my commas different from the rest of the universe. But I've "fixed" enough buggy code just by de-linting them I've become a huge fan such tools and am generally willing to give up my own quirks if I can get the rest of the team to use said tools as well.

In this case, I am getting ready to turn some code over so would like it to be as clean as possible with stock tools to my successor.

Thanks again for the pointer to your previous post.

-- Robert

  • Comment on Re^2: perlcritic compliant way to eval?

Replies are listed 'Best First'.
Re^3: perlcritic compliant way to eval?
by haukex (Archbishop) on Jul 22, 2016 at 11:44 UTC

    Hi Robert,

    'do' ... seemed to work at first for me but is acting wonky

    There are some differences between do and eval, maybe that's the problem?

    "do 'stat.pl'; is largely like eval `cat stat.pl`; except that it's more concise, runs no external processes, keeps track of the current filename for error messages, searches the @INC directories, and updates %INC if the file is found. ... It also differs in that code evaluated with do FILE cannot see lexicals in the enclosing scope; eval STRING does."

    Also do requires some more error checking to figure out what went wrong if the file doesn't compile/run, see do.

    Hope this helps,
    -- Hauke D

      Yes, that is the description I read also, it the way it reads makes it sound like do does have advantages over eval so I am very interested in tracking down the issues I had with it. I might not get to it for this code though. I have a couple more weeks so might squeeze it in. I'll report back if I do.