2016-07-13 1 views
-4

새 컴퓨터에 Active Perl 5.10.0 (ActivePerl-5.10.0.1003-MSWin32-x86-285500)이 설치되어 이전 컴퓨터에서 실행했던 코드를 실행했습니다. 암호). 코드는 이전 컴퓨터에서는 정상적으로 작동하지만 새 컴퓨터에서는 정상적으로 작동하지 않습니다.GetOpt not working

cmd.exe에서 시작할 때 .pl 파일을 실행하지만, 내가 추가 한 명령 줄 인수는 무시합니다. 이것은 내가 Getopt :: Long이 인식되도록 뭔가를 놓치고 있다고 생각하게 만든다. 어떤 아이디어? 예를 들어

, 내 코드에 이런 일에 둘 때 "B"는 스크립트의 일부 코드를 설정하는 데 사용되는 인수입니다

Getopt::Long; 
GetOptions(\%args, "b") 

, 그것은 수락하지 않습니다

script.pl -b 

하지만 난의 같은 그것의 앞에 "펄"를 넣어 경우는

script.pl 

는 또한, 인수가 작동합니까 받아 o :

perl script.pl -b 

제공하고자하는 모든 도움에 감사드립니다.

+2

모든 대답은 추측됩니다. –

+0

오류 인쇄/표시 – ssr1012

+0

Strawberry Perl을 어떻게 설치하셨습니까? Perl 파일은 어떻게 실행하고 있습니까? – Borodin

답변

1

이것은 perl 문제가 아닙니다. 이것은 Windows 구성 문제입니다. 특히 .PL 파일 형식 연결이 올바르게 구성되어 있지 않습니다.

ftype 명령을 사용하여 수정할 수 있습니다.

C : 우리는 당신이 실행하고자하는 코드를 볼 수없는> 도움말 FTYPE는

Displays or modifies file types used in file extension associations 

FTYPE [fileType[=[openCommandString]]] 

    fileType Specifies the file type to examine or change 
    openCommandString Specifies the open command to use when launching files 
        of this type. 

Type FTYPE without parameters to display the current file types that 
have open command strings defined. FTYPE is invoked with just a file 
type, it displays the current open command string for that file type. 
Specify nothing for the open command string and the FTYPE command will 
delete the open command string for the file type. Within an open 
command string %0 or %1 are substituted with the file name being 
launched through the assocation. %* gets all the parameters and %2 
gets the 1st parameter, %3 the second, etc. %~n gets all the remaining 
parameters starting with the nth parameter, where n may be between 2 and 9, 
inclusive. For example: 

    ASSOC .pl=PerlScript 
    FTYPE PerlScript=perl.exe %1 %* 

would allow you to invoke a Perl script as follows: 

    script.pl 1 2 3 

If you want to eliminate the need to type the extensions, then do the 
following: 

    set PATHEXT=.pl;%PATHEXT% 

and the script could be invoked as follows: 

    script 1 2 3 
+1

하지만 OP는 Perl 파일이 실행 중임을 나타냅니다. – Borodin

+1

예, 스크립트가 실행되지만 OP에서도 인수를 수락하거나 표시하지 않습니다. 파일 유형 연결에 설정의'% 1 % *'부분이 없기 때문입니다. –

+0

아, 그래서 그들은'perl script.pl'보다는'script.pl'로 파일을 실행하고 있습니다. – Borodin