On Mon, Mar 30, 2009 at 2:20 PM, ANJAN PURKAYASTHA
<anjan.purkayas...@gmail.com> wrote:
> Hi,
> Here is my problem;
> I have a series of arrays with 0s and 1s. here is an example: (1, 0, 1, 1).
> I need to parse through this series of arrays and extract the index of the
> 0s in the array.
> Is there any quick way of doing this?

Millions of ways here is one:


#!/usr/bin/perl -w
use strict;

my @arr = (0,1,1,1,0,0);
my $pos = 0;

for my $index (@arr) {
  if ( $index == 0 ) {
     printf ("%d ", $pos );
  }
  $pos++;
}
print "\n";


> TIA,
> Anjan
>
> --
> =============================
> anjan purkayastha, phd
> bioinformatics analyst
> whitehead institute for biomedical research
> nine cambridge center
> cambridge, ma 02142
>
> purkayas [at] wi [dot] mit [dot] edu
> 703.740.6939
>



-- 
[ Rodrick R. Brown ]
http://www.rodrickbrown.com http://www.linkedin.com/in/rodrickbrown

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to