Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^6: Combining 3 files

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


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

Thanks for the detailed post. I'm still having problems with the "Use of uninitialized value in array element" error. I adjusted the code, however I'm not sure where I need to insert the equivalent of the

next unless $meat;

I can get it to work by commenting out use strict;

##!/usr/bin/perl #22/06/2011 use strict; use warnings; use File::Slurp; use Data::Dumper; my @data; my @col; my $dataset; my @fields; my %out; my $Hashref; my $fileCount; my @out; open INFILE, "<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; } } while (<INFILE>){ @col = split(/\t+/, $_); chomp (@col); my ($header, $length, $tm, $sequence) = @col[0..3]; # expecting file3 line in @col my @results = ( $col[1], $col[2] ); #print Dumper (\@results) for my $dataset (@data) { my @out = push @{ $data[ $fileCount ]->{ shift @col } }, \@col; #print Dumper (\@data); #} @out = sort { 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; } @out; print Dumper (\@out); push @results, $out[0]->[2]; } #foreach (@results){ # print $_."\n"} }

Replies are listed 'Best First'.
Re^7: Combining 3 files
by Anonymous Monk on Jun 27, 2011 at 14:58 UTC

    however I'm not sure where I need to insert the equivalent of the

    Next line, right after you initialize $meat

    push @{ $data[ $fileCount ]->{ shift @col } }, \@col;

    Wait a minute, why did you copy that?

      I thought that it was a simplified version of:

      my @beef = @{ $dataset->{ $col[0] } };
        Whatever gave you that impression?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-04-24 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found