http://www.perlmonks.org?node_id=964223


in reply to Re: Common Perl Pitfalls
in thread Common Perl Pitfalls

Great stuff. Thanks for the feedback.
I really like the second solution.
The third solution isn't as portable, though.
Why do you think redefining $/ as I did is a potential problem?

Replies are listed 'Best First'.
Re^3: Common Perl Pitfalls
by JavaFan (Canon) on Apr 09, 2012 at 23:23 UTC
    The third solution isn't as portable, though.
    cat is probably available on more platforms than perl is. Of course, Windows rules the world, and both cat and perl are ported to Windows -- and, AFAIK, neither comes standard with the OS. Unlike cat, perl is not included in the POSIX standard for shell utilities.

    Why do you think redefining $/ as I did is a potential problem?
    Well, you consider someone modifying the code to be a potential problem. Would if someone modifies your code, and adds a return after the first assignment to $/, but before the second? Would if someone wraps the code in an eval, and the read triggers an exception?

      Well, that's a tad too advanced for me at the moment. But thanks for sharing your insight. And I had no idea that cat was ported to Windows. I was never what you can call a Windows power user. Thankfully, I switched to Linux :)