in reply to Formatting clue

If you put use warnings; at the top of your code you would get some hints that you have a problem.

Your 2 regexes work for two different lines. The first line matches the left regex, and the first 5 special vaiables are set ($1 - $5). But, since $6 is not set from the 1st input line, you get a warning "Use of uninitialized string...".

The 2nd line matches the right regex, but it only sets $1. Maybe you're looking for something more like this:

use strict; use warnings; while (<DATA>) { chomp; s/^\s+//; s/\s+$//; my @tokens = split /\t/; if ((scalar @tokens) == 5) { print $_; } elsif ((scalar @tokens) == 3) { if (/number=(.*)/) { print "\t$1\n" } } } # not sure how many tabs you have in your 2nd line __DATA__ Chr21 NT_113958 STS 76092 76265 Chr21 NT_113958 number=1

Replies are listed 'Best First'.
Re^2: Formatting clue
by cowboy007 (Initiate) on Feb 18, 2009 at 03:16 UTC
    Ya thats a great idea.. Thanks