this is related to my previous question, getting pretty stuck with my next problem!
i have an array of arrays:
i have manged to read the data into an array of arrays, i did end up using regexp in the end:
my next problem is that I need to search this array of arrays - I know how to search a regular array, but in this case I need to search the first element and match the number part of it, i.e. each record looks like this:
[code
["ID1:HUF000G" "some text here" "ID2" "ID3"]
[/code]
and I need to match the first field so if i am searching for "HUF000G" the whole of that array is returned... any hints? been searching everywhere for some syntax, but couldn't find anything relevent... also, i appreciate this would be easier if i used a hash, but that's no possible as there is no unique identifier for each record i.e. there is more than one array in the array or arrays that contains HUF000G and I need to return all of them,
thanks
i have an array of arrays:
i have manged to read the data into an array of arrays, i did end up using regexp in the end:
Code:
@records = <DATA>;
foreach $record (@records) {
if ($record =~ /\s*(\S+)\s(.+) > (.+) ; (.+)/) {
$id1 = $1;
$id2 = $2;
$id3 = $3;
$id4 = $4;
@temp = ($1, $2, $3, $4);
push @AoA, [ @temp ];
}
}
my next problem is that I need to search this array of arrays - I know how to search a regular array, but in this case I need to search the first element and match the number part of it, i.e. each record looks like this:
[code
["ID1:HUF000G" "some text here" "ID2" "ID3"]
[/code]
and I need to match the first field so if i am searching for "HUF000G" the whole of that array is returned... any hints? been searching everywhere for some syntax, but couldn't find anything relevent... also, i appreciate this would be easier if i used a hash, but that's no possible as there is no unique identifier for each record i.e. there is more than one array in the array or arrays that contains HUF000G and I need to return all of them,
thanks