diff --git a/cameo/zstack.pl b/cameo/zstack.pl index e5c1d2e..bd5d27f 100755 --- a/cameo/zstack.pl +++ b/cameo/zstack.pl @@ -14,7 +14,7 @@ sub usage { - print STDERR "usage: $0 z-start z-maxstep [file ...]\n"; + print STDERR "usage: $0 [-r] z-start z-maxstep [file ...]\n"; exit(1); } @@ -35,6 +35,11 @@ sub issue } +if ($ARGV[0] eq "-r") { + shift @ARGV; + $reverse = 1; +} + $z0 = shift @ARGV; $zs = shift @ARGV; @@ -50,9 +55,18 @@ while (<>) { } $z = $3 if /^-?\d+(\.\d*)?\s+-?\d+(\.\d*)?\s+(-?\d+(\.\d*)?)/; $s .= $_; + $zmax = $z if $z > $zmax || !defined $zmax; } $z{$z} .= "$s\n"; +if ($reverse) { + for (keys %z) { + ($t{$zmax-$_} = $z{$_}) =~ + s/^(-?\d+(\.\d*)?)\s+(-?\d+(\.\d*)?)\s+/$3 $1 /mg; + } + %z = %t; +} + $z = $z0; for $c (sort { $b <=> $a } keys %z) { while ($z > $c+$zs) {