2014-01-13 3 views
-1

이 코드가 있습니다펄의 정규 표현식 오류

sub makeNonVerbatimSubstitutions { 
    my $self = shift; 
    my $input = shift; 
    $input =~ s/^(\S.*)$/(?{$self -> makeOneNonVerbatimSubstitution ($&)}))/mge; 
    return $input; 
} 

을하지만 펄 정규 표현식과 일치 좋아하지 않는다 :

Use of ?PATTERN? without explicit operator is deprecated at RTFWriter.pm line 146. 

문제점은 무엇입니까?

+1

'진단 사용; – toolic

답변

3

대체 오른쪽에있는 코드에 확장 패턴을 사용하고 있습니다. 제가 알고있는 한 작동하지 않습니다. 그리고 필요하지도 않습니다. 또한 /e 수정자를 사용하여 평가하려고합니다. 당신이 필요한 것은 아니라 : 물론 당신이 /m 수정과,이 또한 문자열 내부의 대체를 적용 알고 있습니다

$input =~ s/^(\S.*)$/$self->makeOneNonVerbatimSubstitution ($&)/mge; 

있지만, 그것은 "줄 바꿈"역할을 할 수있는 줄 바꿈을 찾아야한다.

또한 동일한 긴 이름의 서브 루틴 이름은 제가 선택한 것이 아닙니다. 서브 루틴 기능을 명확하게해야하는 경우 대신 주석을 사용하십시오.

도구 설명에 따르면 use diagnostics 인 경우 오류에 대해 자세히 설명합니다. 기본적으로는 사용되지 않으며, 또한, 그것은 닫는와 Questionmark ?을 찾을 수있는 ? ... ? 패턴을 시작 생각한다는 것을 의미

Use of ?PATTERN? without explicit operator is deprecated at -e line 1 (#1) 
    (D deprecated) You have written something like ?\w?, for a regular 
    expression that matches only once. Starting this term directly with 
    the question mark delimiter is now deprecated, so that the question mark 
    will be available for use in new operators in the future. Write m?\w? 
    instead, explicitly using the m operator: the question mark delimiter 
    still invokes match-once behaviour. 

Search pattern not terminated or ternary operator parsed as search pattern at 
     -e line 1 (#2) 
    (F) The lexer couldn't find the final delimiter of a ?PATTERN? 
    construct. 

    The question mark is also used as part of the ternary operator (as in 
    foo ? 0 : 1) leading to some ambiguous constructions being wrongly 
    parsed. One way to disambiguate the parsing is to put parentheses around 
    the conditional expression, i.e. (foo) ? 0 : 1. 

: 이것은 내가 유사한 코드를 실행했을 때 내가 가진 것입니다. 이것이 의미하는 바는 여기서 유효하지 않기 때문에 (?...이 파서에 의해 인식되지 않는다는 것입니다.

1

줄에 괄호가 하나 이상 필요합니다. 대신에 :

$input =~ s/^(\S.*)$/(?{$self -> makeOneNonVerbatimSubstitution ($&)}))/mge; 

읽어야

$input =~ s/^(\S.*)$/(?{$self -> makeOneNonVerbatimSubstitution ($&)})/mge; 

(I 마지막 괄호를 제거 참고).