프로그램밍언어/PERL

PERL 파일 열기 읽기 닫기 삭제

고요한하늘 2014. 6. 20. 00:20

파일 삭제


if ( -e $output_file ) {
  unlink $output_file or die "cannot remove output file: $!";
}


파일 열기 , 닫기

open(INPUT, $keywords_file) or die "cannot open input file: $!";
close(INPUT);

파일 읽기
while ( <INPUT> ) {
  chomp; $total++;
  my ($unique_id, $named_entity, $clues) = split(/\t/);
 
  #next unless exists $top_persons->{$named_entity};
  $valid++;
  $persons{$named_entity} = [] unless exists $persons{$named_entity};
  push @{$persons{$named_entity}}, { id=>$unique_id, clues=>$clues };
}