Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Assigning the Length of an Array to a Variable
by toolic (Bishop) on Aug 25, 2013 at 22:58 UTC | |
|
Re: Assigning the Length of an Array to a Variable (INDEX)
by Anonymous Monk on Aug 25, 2013 at 23:46 UTC | |
by Anonymous Monk on Aug 26, 2013 at 05:06 UTC | |
by AnomalousMonk (Archbishop) on Aug 26, 2013 at 07:20 UTC | |
by Anonymous Monk on Aug 26, 2013 at 05:41 UTC |