in reply to how to make first element of an string as a the array name
(When you post your code, please remember to read the Writeup Formatting Tips.)
now i want to make each line as an array and give the first one as the name of thePlease don't use variables as variable names (yes this still applies).
like this
@IL12::1::287 = ('6','-17','-9','-21','-24','-15','-2','11','4','4','-15','-26','-16','-9','-18','-25','27','17','6')
Second, you'd do better to store your arrays as references in a hash, where the keys to the hash could be 'IL12::1::287', 'IL12::1::329', etc.
(Update: thezip gives you an example of the data-structure below.)
As for the array "common elements" problem, the usual way to solve that is to build a hash containing the elements of the first array as keys, then to loop through the elements of the second array testing for existence in the hash.
-David# you have @arr1 and @arr2 my %lookup = map { $_ => undef } @arr1; my @common = grep { exists $lookup{$_} } @arr2;
|
|---|