
BillKSmith
Veteran
Nov 11, 2010, 10:40 AM
Post #2 of 2
(274 views)
|
Re: [navishkumarb] "Out of memory"
[In reply to]
|
Can't Post
|
|
Your while loop fills memory with copies of the first data item which contains 'END IONS'. I am not sure exactly what you want, but in any case the following code will be close. Run it and observe how the input data gets organized. If it seems reasonable, try it with real data. (Uncomment the open and comment out the statement about *DATA.) Make changes as necessary. Continue to use Dumper to verify your results.
#!C:/Perl/bin/perl.exe use strict; use warnings; use Data::Dumper; *Peptide1 = *DATA; #open( Peptide1, '<', "data.txt" ) || die("cannot open file"); my @data = <Peptide1>; chomp @data; my @daten; close(Peptide1); my $i = 0; my $j = 0; foreach my $dat (@data) { $daten[$i][$j] = $dat; if ( $dat =~ m/END IONS/ ) { $i++; $j = -1; } $j++; } print Dumper @daten __END__ 00 01 02 03 END IONS 10 11 12 13 END IONS 20 21 23 END IONS Good Luck, Bill
|