I am using Cygwin version 2.10.0 with perl 5.26.0. I need to change getopts.pl to Getopt::Std but what to do with &Getopts('F:f:'); line then?

#! /usr/bin/perl
require "getopts.pl" ;

# Perl script to take particle data and
# plot using (in this case) GMT to 
# produce a postscript file of specified size.
# Assumption is that this is a frame for a movie
# and hence that time information is meaningful

# Options:   -f: Filename for input data
# Options:   -F: Filename (root) for output data

# default values for parameters if not specified
if($opt_F eq "") {
  $opt_F = "ascii-conversion";

# Read the particle file ...   Assume 2D !! 
open(PAR,"< $opt_f") || die "File not found $opt_f\n";
open(OUT,"> $opt_F") || die "File not found $opt_F\n";
# open(OUT,">$name") || die "Cannot open file $name : $!\n";

closed as unclear what you're asking by Jeff Schaller, Kusalananda, Romeo Ninov, Anthony Geoghegan, phk Mar 24 '18 at 18:26

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


See Getopt::Std: You should be able to just replace

require "getopts.pl";


use Getopt::Std;

If you also use warnings; and use strict; (as is generally recommended), you'll need to declare the variables beforehand with our ($opt_F, $opt_f);. Alternatively, you can use a hash:

getopts('F:f:', \my %opts);
$opts{f} # instead of $opt_f
$opts{F} # instead of $opt_F
  • Thank you so much..first part worked. no needed to use declaration of variables. – Naside Ozer Mar 22 '18 at 18:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.