如何用perl切割这样的句子

来源:百度知道 编辑:UC知道 时间:2024/05/23 01:30:34
List the flights from Beijing to Seattle . And the flights from Beijing to Chicago .
@12 @28 @a1 @6a @BJ @52 @11 @-- @17 @21 @33 @62 @54 @91 @41 @--

I need a flight from Beijing to Newark . And from Newark to New York . I 'd like to fly back to Beijing the next day .
@09 @8a @a4 @21 @90 @BJ @32 @89 @-- @15 @14 @19 @79 @08 @63 @-- @45 @8a @14 @55 @a0 @67 @93 @BJ @29 @36 @7a @--

文本按1行单词1行标注再1行空行的顺序显示。每个单词底下都对应一个标注。单词与单词之间,标注与标注之间都用一个空格隔开。每个单词的标注都是不同的,其中句号的标注是@--

想把同行的句子分割开,在同一行中只有一个句子,如下所示。代码怎么写??????

List the flights from Beijing to Seattle .
@12 @28 @a1 @6a @BJ @52 @11 @--

And the flights from Beijing to Chicago .
@17 @21 @33 @62 @54 @91 @41 @--

I need a flight from Beijing to Newark .
@09 @8a @a4 @21 @90 @BJ @32 @89 @--

And from Newark to New York .
@15 @14 @19 @79 @08 @63 @--

I 'd like to fly back to Beijing the next day .
@45 @8a @14 @55 @a0 @67 @93 @BJ

先把你的原文存入文件niming.dat,然后用下面的脚本。
#! /usr/bin/perl
open(DAT, "< niming.dat");

while(<DAT>) {
chomp;
if (/\@/) { $sym .= $_; } elsif (/\w+.*/) { $worte .= $_; } else { next; }
}

@route = split /\./, $worte;
@symbol = split /--/, $sym;

$cnt = (@route - 1);
foreach $i (0 .. $cnt) {
print "$route[$i].\n";
print "$symbol[$i]-- .\n";
}

close DAT;

去chinaunix.net的perl版找flw

听不明白,