とりあえず,以下で簡易的には取れる. #!/usr/bin/perl # INPUT $cabocha -f1 -O1 test.txt > test2.txt $input = &argcut($ARGV[0]); open(INPUT, "$ARGV[0]") or die "cant open $ARGV[0]"; open(OUT,">$input") or die "cant open $ARGV[0]"; $aster; $line; while(<INPUT>){ chomp; if(/^EOS/){ $line++; print "$line"."="."$aster\n"; $aster = 0; } elsif(/^*/){ $aster++; } } sub argcut{ my($file) = @_; if(-e $file){ if($file =~ /(\w+)\.(\w+)$/){ $newfile = $1.".csv"; } else{x $newfile = $file.".csv"; } } else { print "cant find $file\n"; } return $newfile; }