Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: filtering an array

by jwkrahn (Monsignor)
on Sep 01, 2012 at 20:18 UTC ( #991192=note: print w/ replies, xml ) Need Help??


in reply to filtering an array

push @positions, [ $read->end + 1, $base ];
i would like to remove every line of this array that contains a G or a T as the string
@positions = grep $_->[ 1 ] =~ /ac/i, @positions;
i would like to get rid of the strings altogether, so i just have an array with one column representing the number
@positions = map $_->[ 0 ], @positions;


Comment on Re: filtering an array
Select or Download Code
Replies are listed 'Best First'.
Re^2: filtering an array
by prbndr (Acolyte) on Sep 01, 2012 at 22:30 UTC
    this code gives the warning: Use of uninitialized value in pattern match (m//). what exactly does this mean?

      You are using a variable in a pattern matching regular expression and said variable currently has no value. Please try assigning a value to the variable and see what happens. Thanks.

        i see. so if my array @positions is already defined and created, do i need to loop over all the values in @positions and then execute the code you posted?

        something like:

         for (@positions) {@positions = grep $_->[1] =~ /ac/i, @positions;}

        and then:

         for (@positions) {@positions = map $_->[0], @positions;}

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991192]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2015-07-31 13:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (277 votes), past polls