"yes" and "not without a backup and some tests" respectively.
In the few cases I've seen perltidy break code, it broke in such a way that the resulting syntax was invalid (this was a couple of years ago, I can't remember the specifics), so running "perl -c" against the resulting code should give you some indication - if it fails, your code was mangled.
update: just to clear this up: I don't use perltidy all that regulary, but I've used it a couple of times in the last year, and I haven't seen any breaks then (on about 50 files or so). All breaking I've experienced was years ago - this probably depends on your coding style - YMMV.
update 2: also "if it fails, your code was mangled" does not imply that your code isn't mangled if "perl -c code.pl" succeeds.
| [reply] |
No static independent parsing of Perl can completely understand /usr/bin/perl's parsing of a given Perl program. See my (now classic) On Parsing Perl for examples and an explanation.
Therefore, there will be always be a risk of breakage. If you have a good test suite, be sure to use that.
| [reply] [d/l] |
I don't think I have ever had perltidy() break my code in the four or five year I have been using it. I have seen it flush out syntactical faux-pas on my part; but I have not had it generate broken code, unless the code was already broken to begin with. That said, I always run what ever test-suite I have available against both the original code and the perltidy'd code and then explain all of the diffs before I rename/commit/production-ize the .tdy file. Just another Old Paranoid Programmer, I suppose.
----
I Go Back to Sleep, Now.
OGB
| [reply] |
| [reply] |
In the same spirit (more of an FYI for the OP), 'perldoc perltidy' does say
| MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!" | | I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README). | | ** The third rule of perl club is a statement of fact: pod is sexy. |
| [reply] |
It's your code. Are you going to believe us if we tell you "Go ahead and just do it?" I wouldn't.
| [reply] |