Jose Bento <[EMAIL PROTECTED]> wrote:
> 
> I have a text file (*.doc) that have a list of articles all of them
> separated by the some sequence of characters (NNNN).
> 
> How can I divide this file into several files each one with only one
> article?
> 

Assuming they aren't huge articles...

#!/usr/bin/perl

use strict;
use Fatal qw/open close unlink/;

eval {
    local $/ = "NNNN\n";
    open IN, 'articles.doc';

    while (<IN>) {
        chomp;
        open  OUT, ">article_${.}.doc";
        print OUT;
        close OUT;
    }

    close IN;
    unlink 'articles.doc';
};

warn $@ if $@;


HTH
-- 
Steve

perldoc -qa.j | perl -lpe '($_)=m("(.*)")'

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to