Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: substitute 4 spaces instead of a tab

by anneli (Pilgrim)
on Nov 07, 2011 at 10:40 UTC ( #936471=note: print w/ replies, xml ) Need Help??


in reply to Re: substitute 4 spaces instead of a tab
in thread substitute 4 spaces instead of a tab

With regards to not truncating anything accidentally, davido mentioned this excellent suggestion: move the original file out of the way first (e.g. if it's called shock_api.h, call it shock_api.h.bak or similar; there's a built-in called rename to do this), then read in from shock_api.h.bak and write out to shock_api.h.

This solves the simultaneous read/write truncation issue, and creates a backup for you in case things go awry.


Comment on Re^2: substitute 4 spaces instead of a tab
Select or Download Code
Replies are listed 'Best First'.
Re^3: substitute 4 spaces instead of a tab
by davido (Archbishop) on Nov 07, 2011 at 16:53 UTC

    In fact my suggestion isn't exactly original either. Take a look at perlrun under the -i flag. When you instruct Perl do to in-place edits from the command line like this, "perl -i.bak ....." you get essentially the same behavior.


    Dave

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2015-07-30 23:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls