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

Re: difficulty in matching 2 fields of a same line

by 2teez (Priest)
on Jun 27, 2012 at 18:02 UTC ( #978736=note: print w/replies, xml ) Need Help??

in reply to difficulty in matching 2 fields of a same line

You can use array slice like so:

my @line; while(<DATA>){ chomp; push @line,split; } print @line[2,10]; #print 3,11 __DATA__ 4829:71370 1:N:0:CGATGT + chr6 126912761 GAAGGCATAGCCCGTTGGGCTGTGGTCAT +CAGCCTC CCCFFFFFHGHHHJHIJJJHIJIGHCGIIJJJJIJI 0 4829:71370 2:N:0:CGATGT + chr7 89349071 AGCCCTGCCCCCACCCCCCATTCTTCTTGACTGTCT C@@F +FFFFHHHGHJ JIJIJIIIIJJJJJJJJIIJIJ 0

However, it really depend on what you really want to print out.

Replies are listed 'Best First'.
Re^2: difficulty in matching 2 fields of a same line
by Anonymous Monk on Jun 27, 2012 at 18:09 UTC

    my code shud not be printing this line because here both fields are equal
    but it does because there are sm extra tabs.

    how do i tell it to compare only those fields starting with chr?

      Let a regex find what you need
      my @cmp = $line[$i] =~ /\tchr([0-9]+)\t/g; if (2 == @cmp and $cmp[0] != $cmp[1]) { print $line[$i]; }

        hey thanks for that u guys are really amazing!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://978736]
[choroba]: bare SQL seems to work differently. Failing a prepared statement doesn't abort the transaction. So it's a behaviour of the DBD driver
[choroba]: and smells like a bug
[choroba]: oh wait
[choroba]: it doesn't abort, but it blocks any other operations than aborting
[choroba]: so it kind of makes sense
[huck]: "Aaarrr!"

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2017-09-19 14:15 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (222 votes). Check out past polls.