If I want to an in-place update of a file with perltidy, how can I do it? Let's say I want to run perl-tidy on foo.pl
but I want to the changes to be in foo.pl
Asked
Active
Viewed 298 times
2

Evan Carroll
- 78,363
- 46
- 261
- 468
2 Answers
4
You would use the options -b
and -bext='/'
perltidy -b -bext='/' foo.pl
Make sure you don't have -st
provided or the -b
and -bext
options do nothing; this was actually my problem.

Evan Carroll
- 78,363
- 46
- 261
- 468
3
It looks like perltidy
has a native solution. Not all programs do. The sponge
utility can be used to achieve in-place editing for programs that don't natively support it.
prog file | sponge file

ikegami
- 367,544
- 15
- 269
- 518
-
1@JRFerguson, Kinda. It links to the other answer. I wanted to acknowledge that this might not be the best answer in this specific case, but it might help others. – ikegami Jun 05 '20 at 20:09