HELP 옵션과 VERBOSE 설정을 예로



my $options = {}; # `my' defines a local variable.
getopts("hv", $options);
$debug_mode = $options->{v};
 
sub print_usage_and_exit {
  my $fh = shift || *STDOUT;
  my $message = shift;
 
  print $fh $message, "\n" if defined $message;
  print $fh <<END;
Usage: $0 [-h] [-v] [-v] <keywords_file> [<output_file>]
 keywords_file             - input filename which lists keywords
 output_file               - output filename to write
 
 Options -
  -h          shows this help message
  -v          enables verbose mode
END
  exit;
}
 
print_usage_and_exit if $options->{h};

'프로그램밍언어 > PERL' 카테고리의 다른 글

PERL MAP 사용법  (0) 2014.06.20
PERL 파일 열기 읽기 닫기 삭제  (0) 2014.06.20
PERL SUB 모듈에서 파라미터 받기  (0) 2014.06.20
PERL 변수 선언 및 특이 표현  (0) 2014.06.20
PERL 선언시 모듈 import  (0) 2014.06.20
Posted by 고요한하늘
,