I have an array (@myarray) with strings as such:
rs30000489
rs903484
rs24567;rs324987;rs234985
rs5905002
rs32456;rs2349085
When I match another similar (@otherarray) array without strings with semicolons and multiple rsIDs, with the following code:
for $1(0 .. $#otherarray) {
for $m(1 .. $#myarray) {
if ($myarray[$m] =~ /$otherarray[$i]/i) {
$IDmatch = 1;
}
}
}
The script does not match any of the IDs within strings with semicolons. I tried splitting the semicolon strings like such:
foreach $string (@myarray) {
if ($string =~ m/;/) {
push (@newarray, $string);
}
}
Which returns the array @new:
rs24567;rs324987;rs234985
rs32456;rs2349085
Which I then try to split it by a common character as such:
foreach $line (@new) {
$line =~ tr/;//d;
$line =~ s/rs/ rs/g;
$line = split (/ /);
}
But when I print the @new array it just returns zeros. I know this must have something to do with my loop because I have trouble working with loops in perl. Please let me know if you have any ideas! Thanks!
without strings with semicolons and multiple rsIDsWithout strings with semi-colons sounds like its only semi-colons. You should almost always show instead of describe.'split'is not really a split. Its a matching for;and then pushing it to@new@otherarrayhas other kinds of strings. Which doesn't really say anything, if you think about it. To make things easier, you should just show sample data, like you did with the first array.