Use emacs in batch mode.
With this emacs lisp code in file "perl-indent.el":
(cperl-mode) (indent-region 0 (buffer-size) nil) (save-buffer)
And this emacs command line call:
> emacs -batch try.pl -l .emacs -l perl-indent.el
This file "try.pl":
#!/usr/bin/perl -w use strict; for (1) { print "emacs rules"; } while (1) { print " ... at least in viper mode\n"; }
turns into:
#!/usr/bin/perl -w use strict; for (1) { print "emacs rules"; } while (1) { print " ... at least in viper mode\n"; }
The call to the ".emacs" initialization file is necessary since emacs won't load it per default in batch mode, and you want your personal indentation preferences to be used, of course.
Christian Lemburg
Brainbench MVP for Perl
http://www.brainbench.com
In reply to Re: how to indent/pretty print perl code
by clemburg
in thread how to indent/pretty print perl code
by snowcrash
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |