Skip to content

Commit

Permalink
add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
triffid committed Dec 10, 2011
1 parent 359d407 commit ca25494
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions post-processing/z-every-line.pl
Expand Up @@ -4,18 +4,20 @@

my $z = 0;

# read stdin and any/all files passed as parameters one line at a time
for (<>) {
if (/Z(\d+(\.\d+)?)/) {
$z = $1;
print;
# if we find a Z word, save it
$z = $1 if /Z(\d+(\.\d+)?)/;

# if we don't have Z, but we do have X and Y
if (!/Z/ && /X/ && /Y/ && $z > 0) {
# chop off the end of the line (incl. comments), saving chopped section in $1
s/\s*([\r\n\;\(].*)//s;
# print start of line, insert our Z value then re-add the chopped end of line
print "$_ Z$z $1";
}
else {
if (!/Z/ && /X/ && /Y/ && $z > 0) {
s/\s*([\r\n\;\(].*)//gs;
print "$_ Z$z $1";
}
else {
print;
}
# nothing interesting, print line as-is
print;
}
}

0 comments on commit ca25494

Please sign in to comment.