Cinzia Sala wrote:
> Dear all,

Hello,

>     I would like to separate my input text DB-file into single files
> each containing the information between the two separators "//"
> 
> 
> e.g.
> 
> dog, cat, home
> home, dog, cat
> //
> pen, pencil, work
> //
> milk, water, wine
> wine, milk, water
> //end
> 
> I have tried with this:
> 
> do {
>     $/="//\n";
>     $record= <DBFILE>;
>     print $record;
>     }    until ($/="//end");
> 
> 
> but it prints only:
> 
> dog, cat, home
> home, dog, cat
> //
> 
> How can I print in separate files the other records?

my $count;

while ( <DBFILE> ) {
    if ( $. == 1 || m!^//! ) {
        open OUT, '>', 'file' . ++$count or die "Cannot open file$count: $!";
        next if m!^//!;
        }
    print OUT;
    }



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to