There is a pile of stuff that can be tidied up there. First off, always use strictures (use strict; use warnings;).
Use the three parameter version of open and check the result. Use lexical file handles:
open my $inFile, '<', "MOUSE_TF1.txt" or die "Failed to open MOUSE_TF1 +.txt: $!";
Instead of using "parallel" data structures that have to be handled piecemeal, group common data using a hash:
use warnings; use strict; open my $inFile, '<', "MOUSE_TF1.txt" or die "Failed to open MOUSE_TF1 +.txt: $!"; my %families; my @fields = qw(chr start end symbol strand); while (<$inFile>) { my $line = $_; chomp ($line); my @Gene_Info = split "\t", $line; my $id = shift @Gene_Info; @{$families{$id}}{@fields} = @Gene_Info; } close $inFile; # select Gene Symbols belonging to "Hox" family and print foreach my $key (keys %families) { if ($key =~ /Hox/) { print join ("\t", $key, @{$families{$key}}{@fields}), "\n"; } }
untested
In reply to Re: If Statements and Regular Expressions
by GrandFather
in thread If Statements and Regular Expressions
by TempAcolyte
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |