perlquestion
sokatron
Hi,
Im new here and somewhat new to PERL. Im trying to learn how to apply some PERL to our research data.
I seem to run into a problem when I want each for-loop to create a separate array from that loop.
In my makeshift solution below I made an array within an array, where each array in the AoA represents a number of values for each sample.
The problem then, is that I cannot extract each array and put into a separate array, it seems to be a easy question, perhaps the answer is to obvious.
@A = @B[0]; This did not work to transfer the first array into a separate array.
It also presents a problem because I would need to declare X new arrays (one for each sample) and then Im back in the looping and declaring.
Any help or suggestions would be appreciated
Cheers
Oskar
<code>
#!/usr/bin/perl
use strict;
my ($antal);
my ($size);
print "How many replicates? ";
$antal = <stdin>;
print "How many Samples? ";
$size = <stdin>;
my ($tam);
my ($tim);
$tim = 0;
my ($x);
my (@a);
my ($repvalue);
my ($repvalue2);
$repvalue2 = 1;
for ($x=0; $x<$size; $x++) #For each Sample the number of replicates are entered
{
for ($tam=0; $tam<$antal; $tam++ ) #For each replicate in the sample a value is added
{
$repvalue = $tam+1;
print "Imput replicate value $repvalue for sample $repvalue2: ";
$a[$tim][$tam] = <stdin>;
}
$repvalue2++;
$tim++;
print "\n";
}
my ($n);
my ($m);
my ($n2);
my ($m2);
for ($n = 0; $n<$size; $n++) #For printing and checking all values
{
print "\n\n";
$n2 = $n+1;
print "Replicates of sample $n2:\n\n";
for ($m=0; $m<$antal; $m++)
{
$m2 = $m+1;
print "Replicate $m2 value is: $a[$n][$m]";
}
print "\n\n";
}
</code>