I have a script that I wrote to take a tab- delimited file and split it into six constituent files. While I must admit that the code is probably childishly lengthy, it was the only way I could think Firstly I was wondering how you could do this in aforeach such that the name of each file that's passed would go to $filein. Also is there a way to remove ^M and other gibberrish in the original file I would like to do the cleanup in another script. Thank you in advance. #! /usr/local/bin/perl -w
BEGIN { push @INC, '/net/cbc/lib.orig/perl'; } use strict; use File::ReadCSV; my $f; my $myfile; my $filein = "cdm_bhi_051101_t10n"; my $fileout; $fileout = $filein.".user"; open OUT, ">$fileout" or die "couldnt open output file $fileout\n"; while(<>){ if ( /^Begin/ ){ last; } elsif ( /^Version/ ) { print OUT $_; next; } elsif ( /^$/ ) { next; } else { print OUT $_; } } close OUT; $fileout = $filein.".protocol"; open OUT, ">$fileout" or die "couldnt open output file $fileout\n"; while(<>){ if ( /^Begin/ ){ last; } elsif ( /^End/ ) { next; } elsif ( /^$/ ) { next; } else { print OUT $_; } } close OUT; $fileout = $filein.".image"; open OUT, ">$fileout" or die "couldnt open output file $fileout\n"; while(<>){ if ( /^Begin/ ){ last; } elsif ( /^End/ ) { next; } elsif ( /^$/ ) { next; } else { print OUT $_; } } close OUT; $fileout = $filein.".normal"; open OUT, ">$fileout" or die "couldnt open output file $fileout\n"; while(<>){ if ( /^Begin/ ){ last; } elsif ( /^End/ ) { next; } elsif ( /^$/ ) { next; } else { print OUT $_; } } close OUT; $fileout = $filein.".measurement"; open OUT, ">$fileout" or die "couldnt open output file $fileout\n"; while(<>){ if ( /^Begin/ ){ last; } elsif ( /^End/ ) { next; } elsif ( /^$/ ) { next; } else { print OUT $_; } } close OUT; -- Shalini Raghavan Center for Computational Genomics and Bioinformatics University of Minnesota ph : 612 - 624 - 9135 e-mail : [EMAIL PROTECTED]