Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: filtering an array

by philiprbrenan (Monk)
on Sep 01, 2012 at 19:41 UTC ( #991187=note: print w/replies, xml ) Need Help??

in reply to filtering an array

use feature ":5.14"; use warnings FATAL => qw(all); use strict; use Data::Dump qw(dump pp); my @positions; for(split /\n/, <<'END') 1 ACAC 2 AGAC 3 AGTC 4 ACCA END {push @positions, [split/ /] unless /[GT]/; } say "With bases: ", dump(@positions); $_ = $_->[0] for @positions; say "Without bases: ", dump(@positions);


With bases: ([1, "ACAC"], [4, "ACAC"]) Without bases: (1, 4)

Replies are listed 'Best First'.
Re^2: filtering an array
by philiprbrenan (Monk) on Sep 01, 2012 at 20:15 UTC

    The script will work as long as the string is one or more characters long and does not contain spaces.

Re^2: filtering an array
by prbndr (Acolyte) on Sep 01, 2012 at 19:50 UTC

    i should say that the string is just one single letter, either an "A" "T" "G" or "C", not multiple letters combined.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991187]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2018-06-24 17:40 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.