getopts.pl을 Getopt::Std로 교체하세요.

getopts.pl을 Getopt::Std로 교체하세요.

저는 Cygwin 버전 2.10.0과 Perl 5.26.0을 사용하고 있습니다. getopts.pl으로 바꿔야 하는데 Getopt::Std라인은 어떻게 되나요 &Getopts('F:f:');?

#! /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

&Getopts('F:f:');
# 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";

답변1

바라보다Getopt::Std: 직접 교체할 수 있어야 합니다.

require "getopts.pl";
&Getopts('F:f:');

그리고

use Getopt::Std;
getopts('F:f:');

use warnings;and (일반적으로 권장됨) 도 사용하는 경우 use strict;변수를 미리 선언해야 합니다 our ($opt_F, $opt_f);. 또는 해시를 사용할 수 있습니다.

getopts('F:f:', \my %opts);
$opts{f} # instead of $opt_f
$opts{F} # instead of $opt_F

관련 정보