Thanks Cristoforo,
I modified the code as suggested by you but I thing the program is giving me error of uninitialized values.
#!/usr/bin/perl -w + use strict; use warnings; my $matchfile = "match_super.dat"; my $ctfile = "M23263_rna_300-1.dat_1.ct"; my @match;my %data;my $fragment; my $pos; open (A, "<", $matchfile) or die "Check the file $!\n"; while (my $line = <A>) { chomp $line; (undef, $fragment, undef, $pos) = split(/\t/, $line); $data{$pos} = $fragment; } close (A); my ($num1, $base, $num2, $num3, $connect, $num4); open (B, "<", $ctfile) or die "Check the file $!\n"; while (my $ctline = <B>) { chomp $ctline; if ($ctline =~ /^(\d+\s+dG.*)/) { # print "$1\n"; next; + next; } $pos = (split /\s+/)[0]; print "$data{$pos} $pos\n" if $data{$pos}; } close (B);
Error: Use of uninitialized value $pos in hash element at ./second_str_map.pl + line 29, <B> line 298. Use of uninitialized value $_ in split at ./second_str_map.pl line 28, + <B> line 299. Use of uninitialized value $pos in hash element at ./second_str_map.pl + line 29, <B> line 299. Use of uninitialized value $_ in split at ./second_str_map.pl line 28, + <B> line 300. Use of uninitialized value $pos in hash element at ./second_str_map.pl + line 29, <B> line 300. Use of uninitialized value $_ in split at ./second_str_map.pl line 28, + <B> line 301. Use of uninitialized value $pos in hash element at ./second_str_map.pl + line 29, <B> line 301.
In reply to Re^6: Key value pair in hash inside while loop
by newtoperlprog
in thread Key value pair in hash inside while loop
by newtoperlprog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |