,perl 배열에서 여러 값을 가져 오는 가장 좋은 방법은 무엇입니까? 우선
, 난
my @dataRecord = split(/\n/);
다음에,이 같은 시험 라인을 얻을 수있는 배열 데이터 레코드에 필터링이 같은 배열로 dataRecord 얻을
@dataRecord = grep(/test_names/,@dataRecord);
다음으로, 나는이 같은 테스트 라인에서 테스트 이름을 얻을 필요가
my ($test1_name,$test2_name,$test3_name) = getTestName(@dataRecord);
sub getTestName
{
my $str = shift @_;
# testing the str for data and
print str,"\n"; # This test point works in that I see the whole test line.
$str =~ m{/^test1 (.*), test2 (.*), test3 (.)/};
print $1, "\n"; # This test point does not work.
return ($1,$2,$3);
}
이 작업을 수행하는 더 좋은 방법이 있습니까?
돌아 오기 위해? –