a few minor updates for z-every-line

degen-loop-screen
Michael Moon 2012-09-26 18:49:42 +10:00
parent 36a5af831c
commit ab103b0c12
1 changed files with 6 additions and 6 deletions

View File

@ -8,17 +8,17 @@ my $z = 0;
# read stdin and any/all files passed as parameters one line at a time
while (<>) {
# if we find a Z word, save it
$z = $1 if /Z(\d+(\.\d+)?)/;
$z = $1 if /Z\s*(\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;
s/\s*([\r\n\;\(].*)/" Z$z $1"/es;
# print start of line, insert our Z value then re-add the chopped end of line
print "$_ Z$z $1";
# print "$_ Z$z $1";
}
else {
#else {
# nothing interesting, print line as-is
print;
}
print or die $!;
#}
}