An adaptation of this script might work in that regard. It was a shell script I hacked together to reformat occasionally as I worked on things. Given one or more files on the command line, it looks to see if there is a .tdy version of the file present (creating an empty one if not), checks if the current version and the .tdy version differ, and if so, performs a tidy (setting the lines 123 characters-personal preference), not replacing the original if a .ERR file was produced. The .tdy file was also left in place for future comparison.
#!/bin/bash
PERLTIDY='/usr/local/bin/perltidy -l 123 '
TOUCH=/bin/touch
DIFF=/usr/bin/diff
WC=/usr/bin/wc
CP=/bin/cp
if [ $# -gt 0 ]
then
echo Command line: $0 $@
for file in $@
do
if [ ! -e $file.tdy ]
then
$TOUCH $file.tdy
fi
if [ `$DIFF -q $file $file.tdy | $WC -l` -gt 0 ]
then
$PERLTIDY $file
if [ -e $file.ERR ]
then
echo Error detected-not replacing
else
$CP -v $file.tdy $file
fi
else
echo Skipping $file - perltidy on file not necessary
fi
done
else
echo Usage: $0 filename
fi
Update (20 Jan 2004): Added absolute paths to utilities used, to prevent issues with pathing.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|