Hi everyone
i need help to fix this script for my new problem, the script was made by bigearsbilly, i tried only to edit it but failed, so i ask here what to do being unable to contact him.
this is the script
Code:
#!/usr/bin/perl -w
sub usage {
die "Usage: $0 template-file coord-file\n";
}
usage() unless (scalar(@ARGV) == 2); # count params
($template, $data_file) = @ARGV; # get filenames
@ARGV = ($data_file);
@coords = <>; # slurp coordinates
warn "Is '$data_file' a proper coordinate file? It contains non-numerics\n"
if grep /[a-z]/i, @coords;
@ARGV = ($template);
@data = <>; # slurp template
die "No SDEF found! in $template" unless grep /SDEF/, @data;
foreach (@coords) {
next unless /./; # jump blank lines
($nm, $x, $y, $z) = split;
@copy = @data;
# do the sub for SDEF
map {s/(SDEF pos=)[\d .]+(.*)/$1$x $y $z $2/} @copy;
$filename = "$template.$nm";
open OUT, ">$filename";
print OUT @copy;
close OUT;
}
it takes coordinates from a text file
then put them into another file on a particular position (looks after a SDEF pos= card)
saves the file with a filename according to the line number from where the coordinate was taken
what i need to change is this
about 5 or 6 lines before, in the file i need to edit, there is another card that needs to be edited with the same coordinates that go into the SDEF pos= place..
the line looks like:
Code:
14 RCC 6.45 0 10.134 0 0 1 0.55 $cella sorgente
where the cordinates to be edited are only the first 3 numbers
the spaces are mandatory, there are 5 spaces between RCC and the first number and five spaces between the last number and the 0.55 diameter.
I was thinking about adding this to the routine:
Code:
map {s/(14 RCC)[\d .]+(.*)/$1 $x $y $z $2/} @copy;
but seems that this simple solution doesn't work..i get output files that have not been changed at all, just renamed..
what should i do?
thank you for your help