in reply to Re^4: Help with pushing into a hash
in thread Help with pushing into a hash
You're most welcome, jemswira! (And, if you need to bow, bow only to Perl... :)
The errors suggest a failed regex in one or more of the map statements. Here are the lines where the errors occurred:
my %activ = map { s/\.\d+//g; /(.+)\s+\|\s+(.+)/; $1 => $2 } read_fil +e $activin; # Line 20 my %antiox = map { s/\.\d+//g; /(.+)\s+\|\s+(.+)/; $1 => $2 } read_fil +e $antioxin; # Line 21 my %toxin = map { s/\.\d+//g; /(.+)\s+\|\s+(.+)/; $1 => $2 } read_fil +e $toxinin; # Line 22 for ( read_file $uniprot ) { # Line 23 /(.{6})\s+.+=([^\s]+)/; # Line 24 push @activline, "$1 | $2 | $activ{$1}\n" if $activ{$1}; # Line 2 +6 push @antioxline, "$1 | $2 | $antiox{$1}\n" if $antiox{$1}; # Lin +e 27 push @toxinline, "$1 | $2 | $toxin{$1}\n" if $toxin{$1}; # Line 2 +8 }
Sounds like there may be lines in the files with differently-formatted data that the regex fails to match. To see if this is the case, try the following:
for my $file (qw/Activator-PFAM.txt AntiOxidant-PFAM.txt Toxin-PFAM.tx +t/){ for(read_file $file){ say "No Match in File: $file; Line: $_" if !/(.+)\s+\|\s+(.+) +/; } }
This will go through each file and display any line the regex doesn't match. If lines with data on them show, the regex will need to be adjusted. If empty lines show, e.g.,:
No Match in File: test2.txt; Line:
Try adding a grep before the file read that allows only non-blank lines to pass. For example:
my %data = map {s/\.\d+//g; /(.+)\s+\|\s+(.+)/ and $1 => $2 } grep /\S +/, read_file $test2;
If no lines show, I'm not sure what the issue may be. In any case, however, please get back to me or the Monks...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Help with pushing into a hash
by jemswira (Novice) on Aug 31, 2012 at 15:43 UTC | |
by Kenosis (Priest) on Aug 31, 2012 at 16:37 UTC | |
by jemswira (Novice) on Aug 31, 2012 at 16:43 UTC | |
by Kenosis (Priest) on Aug 31, 2012 at 16:59 UTC | |
by jemswira (Novice) on Aug 31, 2012 at 17:31 UTC | |
|