에 해당하며 앞의 Post과 관련 있습니다. 파일에있는 텍스트를 기반으로 일부 접두사를 추가하고 싶습니다.Perl 또는 Bash - 접두사, 제거, 스왑 텍스트는
다음 퍼즐 조각 - 텍스트를 약간 조작하고 잠시 파고 들었습니다.
내 파일은 이제 보여줍니다 (선이 텍스트를 다른 연락을 드릴 것입니다 - 모든 같은 같은 메신저를 보여주는) .. 내가
The place is called Denver.Line 1 and we say "I need this information"!
The place is called Denver.Line 2 and we say 'I need this information'!
The place is called Denver.Line 3 and we say 'I need this information'!
The place is called New York.Line 1 and we say 'I need this information'!
The place is called New York.Line 2 and we say 'I need this information'!
그래서 필요
Denver.Line 1 ExtraText I need this information
Denver.Line 2 ExtraText I need this information
Denver.Line 3 ExtraText I need this information
New York.Line 1 ExtraText I need this information
New York.Line 2 ExtraText I need this information
나는 접두사 필요 lines "ExtraText"를 제거하고 "and say we say '"라고 말하십시오. 각 줄에 "!"을 추가해야합니다.
앞서 전문가에게 미리 감사드립니다. ExtraText
이 시나리오에서 공백을 포함 할 수 있음이
while (<>) {
my ($name, $text) = /^(\S+)\s+\S+\s+(.*)/;
print("This place is called $name and we say \"$text\"!\n");
}
참고
는 "ExtraText"는 "ExtraText"실제 문자열 또는 임의의 문자열? –
입력 파일을 탭으로 구분합니까? – ikegami