Hi Perl Monks! I am trying to define a variable which has a value equal to the length of an array. The part that is giving me trouble, I want the length to vary as I read through the array one element at a time. This is what I thought to do
but terminal returns an error message: syntax error at filter.masks.pl line 55, near "$#info["open(MASK, "/Users/logancurtis-whitchurch/Dropbox/thesis_folder/consen +sus_files/filtered_mask_files/filtered.mask."."$population".".txt") o +r die "can't open masked file\n"; my $mask = <MASK>; while (($n = read MASK, $data, 100000) != 0) { my @info = split(//, $data); foreach $info (@info){ if ($#info[$position] < $start) { #change the element at that position to an 'N' substr($mask,($position),1,'N'); $position++; } if (($#info[$position] >= $start) && ($#info[$position] <= $en +d) { $position++; } if ($#info[$position] > $end) { $count++;
Is there a proper way write a variable that equals the current length of the array, at the position equal to the value of my incrementing 'position' variable?
In reply to Assigning the Length of an Array to a Variable by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |