Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^3: Prepending to a file

by ibm1620 (Pilgrim)
on Oct 01, 2016 at 03:32 UTC ( #1173047=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Prepending to a file
in thread Prepending to a file

Instead of

or die "Could not open file ", FILE, ": $!";

don't you want

or die "Could not open file ", $file, ": $!";

Replies are listed 'Best First'.
Re^4: Prepending to a file
by afoken (Canon) on Oct 01, 2016 at 06:49 UTC
    or die "Could not open file ", $file, ": $!";

    Looks good. It seems you found a bug.

    Because filenames may contain spaces and other "invisible" characters, especially when the code generating the filename has a bug (e.g missing chomp), you may want to quote it in the error message. And you could use string interpolation for the filename. So:

     or die "Could not open file '$file': $!";


    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1173047]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2022-05-23 08:00 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (81 votes). Check out past polls.