Change Details
cameo/fped2d2z.pl |
| 1 | #!/usr/bin/perl |
| 2 | # |
| 3 | # fped2d2z.pl - Convert fped 2D stacks into 2.5D paths with Z information |
| 4 | # |
| 5 | # Written 2012 by Werner Almesberger |
| 6 | # Copyright 2012 Werner Almesberger |
| 7 | # |
| 8 | # This program is free software; you can redistribute it and/or modify |
| 9 | # it under the terms of the GNU General Public License as published by |
| 10 | # the Free Software Foundation; either version 2 of the License, or |
| 11 | # (at your option) any later version. |
| 12 | # |
| 13 | |
| 14 | |
| 15 | sub usage |
| 16 | { |
| 17 | print STDERR "usage: $0 prefix [file ...]\n"; |
| 18 | exit(1); |
| 19 | } |
| 20 | |
| 21 | |
| 22 | $pfx = shift @ARGV; |
| 23 | &usage unless defined $pfx; |
| 24 | |
| 25 | $skip = 1; |
| 26 | while (<>) { |
| 27 | if (/^# $pfx.*?(\d+(\.\d*)?)\s*$/) { |
| 28 | $z = $1; |
| 29 | $skip = 0; |
| 30 | } elsif (/^# /) { |
| 31 | $skip = 1; |
| 32 | } |
| 33 | next if $skip; |
| 34 | s/\s+-?\d+(\.\d*)?$/$& $z/; |
| 35 | print; |
| 36 | } |
Download the corresponding diff file