Major assumptions: format you stated (ie name, line 1, line 2) 
  No checking at this point, other than the first read should be > . Also
assumed from your input that you wanted ALL white space removed. Untested,
but a starting point. Also assumed you will setup the open for input and
output accordingly.

my $MyName ;
my $MyLine1;
my $MyLine2;

while( <FILEIN> ){
   chomp;
   if ( /^>(.+)$/ ) {
      $MyName = $1;
      chomp($MyLine1 =<FILEIN>);
      chomp($MyLine2 =<FILEIN>);
      $MyLine1 =~ s/\s+//g;
        $MyLine2 =~ s/\s+//g;
        printf FILEOUT "%-20s\t%-s.%-s\n", $MyName, $MyLine1, $MyLine2;
    }else {
      # error since expecting in format of namex,line1,line2
    }
 }

Wags ;)
-----Original Message-----
From: Pedro A Reche Gallardo [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 14, 2001 13:54
To: [EMAIL PROTECTED]
Subject: PARSING A FILE


Hi to everyone, I have a file that it looks like this

>name1
line 1
line 2
>name2
line a
line b


and I want it to look this way

name1      line1.line2
name2      linea.lineb


Anyone help welcomed
Greetings,

Pedro



--
***************************************************************************
PEDRO a. RECHE gallardo, pHD            TL: 617 632
3824
Scientist, Mol.Immnunol.Foundation,     FX: 617 632 3351
Dana-Farber Cancer Institute,           EM:
[EMAIL PROTECTED]
Harvard Medical School,                 URL: http://www.reche.org
44 Binney Street, D610C,
Boston, MA 02115
***************************************************************************


Reply via email to