I want to create arrays to hold data for a series of people, say @person1, @person2, etc. but the total number of people varies each time I run the program. How do I create arrays (or strings, for that matter) for person1 through personN? I've tried variations on concatenating as seen below, all of which failed.
At its simplest, my question looks like this:
Thanks.
At its simplest, my question looks like this:
Code:
my $i='2';
my $str.$i; # this does not create a string named $str2
Code:
#/usr/bin/perl
use strict;
use warnings;
#create arrays for 5 people
for (my $i=1; $i<5; ++$i) {
my @array.$i;
}
#use 'print' to see if it worked
print "@array1\n";
print "@array2\n";
print "@array3\n";
print "@array4\n";
print "@array5\n\n";
#rest of prog would go here
exit;