| 1 |
|
| 2 |
#!/usr/local/bin/perl -w |
| 3 |
|
| 4 |
################################################################### |
| 5 |
# Perl script: n2mpsprl.prl |
| 6 |
# Call as: n2mpsprl.prl filename |
| 7 |
# If filename is of the form basename.N, where N is an integer, |
| 8 |
# copies file basename.N to file basenameN.mps |
| 9 |
# |
| 10 |
# Copyright 2000, Mauro S. Costa and Peter R. Wilson |
| 11 |
################################################################## |
| 12 |
|
| 13 |
# Test for correct number of input parameters |
| 14 |
die "Invalid command line arguments.\nTry $0 <src> \n" if($#ARGV > 1); |
| 15 |
die "Invalid command line arguments.\nTry $0 <src> \n" if($#ARGV < 0); |
| 16 |
|
| 17 |
# Assign input file name to variable |
| 18 |
$input_file = $ARGV[0]; |
| 19 |
|
| 20 |
## test if ends with a number, exit if not |
| 21 |
if ($input_file =~ /\w\.\d/) { ; } else { exit; } |
| 22 |
|
| 23 |
# Remove the "dot" from the string variable |
| 24 |
# holding the input file name |
| 25 |
$input_file =~ s/\.// ; |
| 26 |
|
| 27 |
# Create a list variable composed of the string variable holding |
| 28 |
# the concatenated input file name and the extension ".mps" |
| 29 |
@name_list = ($input_file,'.mps') ; |
| 30 |
|
| 31 |
# Join the string variables in the name_list variable into |
| 32 |
# a single string variable |
| 33 |
$output_file = join("",@name_list) ; |
| 34 |
|
| 35 |
# create a list variable composed to the parameters needed |
| 36 |
# for the system copy command excution |
| 37 |
@exec_list = ('cp', $ARGV[0], $output_file) ; |
| 38 |
|
| 39 |
# Execute the system copy ("cp") command |
| 40 |
system(@exec_list) ; |
| 41 |
|
| 42 |
############################ end perl script ########################## |
| 43 |
|