Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Combining 3 files

by garyboyd (Acolyte)
on Jun 23, 2011 at 14:52 UTC ( [id://911098]=note: print w/replies, xml ) Need Help??


in reply to Re: Combining 3 files
in thread Combining 3 files

Thanks for your help its most appreciated. I understand the first block of code, but I'm not sure I fully understand the second block in the while (<$fh3>) loop. Could you explain in more detail?

I have been playing around with the script and Data::Dumper and I get an error message:

Use of uninitialized value in hash element at combine_primer_lists.pl line 41, <$fh3> line 1.

Can't use an undefined value as an ARRAY reference at combine_primer_lists.pl line 46, <$fh3> line 1.

#!/usr/bin/perl #22/06/2011 # Usage: perl combine_primer_lists.pl use strict; use warnings; use File::Slurp; use Data::Dumper; my @data; my @col; my %dataset; #open my $fh1, "<Primer-For1" or die $!; #open my $fh2, "<Primer-For2" or die $!; open (my $fh3, '<', "Primer-Rev1") or die $!; open my $outfh, '>', "outputfile.txt" or die $!; for my $nr (1..2) { for my $line (read_file('Primer-For'.$nr)) { my @col = split(/\t/,$line); push @{$data[$nr - 1]->{shift(@col)}},\@col; #print Dumper(\$nr); #print Dumper (\@col); } } while (<$fh3>){ #print Dumper (\$fh3); # expecting file3 line in @col my @results = ($col[0],$col[3]); for my $dataset (@data) { #print Dumper (\@data) push @results,(sort { #print Dumper (\@results) my $diff_a = $col[2] - $a->[1]; $diff_a *= -1 if $diff_a < 0; my $diff_b = $col[2] - $b->[1]; $diff_b *= -1 if $diff_b < 0; $diff_a <=> $diff_b; } @{$dataset->{$col[0]}})[0]->[2]; } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://911098]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (8)
As of 2024-04-25 11:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found