#!/usr/bin/env perl # Update the S/D and M/S ratios in a table. This script can be used with: # perl -i update-ratios # to modify the file in-place, instead of getting the results on stdout. # # Copyright (C) 2012 Vincent Lefevre # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 3 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see http://www.gnu.org/licenses/ # or write to the Free Software Foundation, Inc., 51 Franklin St, # Fifth Floor, Boston, MA 02110-1301, USA. use strict; # UTF-8 settings. use utf8; # for the characters in the script. use open ':encoding(UTF-8)'; # for the file arguments. binmode STDIN, ':encoding(UTF-8)'; # for stdin. binmode STDOUT, ':encoding(UTF-8)'; # for stdout. my $nrx = qr/(\d*)\.(\d\d)/; while (<>) { /^(│ 1 [246] [56] [-246] │ *$nrx +$nrx +$nrx +$nrx *│).{11}│/ or print, next; # Make sure that everything is exactly representable as a binary # floating-point number before the division. my $sipe = (($6.$7) + ($8.$9))/2; printf "%s %3.1f %3.1f │\n", $1, $sipe / ($2.$3), ($4.$5) / $sipe; } # $Id: update-ratios 56954 2012-12-11 15:07:51Z vinc17/ypig $