On 3/17/11 Thu Mar 17, 2011 12:26 PM, "Chris Stinemetz"
<[email protected]> scribbled:
> Rob
>
> Not sure what I am doing wrong but when I incorporate the infile that I want
> to read and process the program does nothing and it seems like my PCMD file is
> never opened.
>
> Below is my code thus far.
>
> Thank you,
>
> Chris
>
> #!/usr/bin/perl
>
> use warnings;
> use strict;
>
> #my $filepath = 'PCMD';
> my $filepath = 'C:/temp/PCMD';
> my $outfile = 'output.txt';
>
> open my $fh, '<', $filepath or die "ERROR opening $filepath: $!";
> open my $out, '>', $outfile or die "ERROR opening $outfile: $!";
>
> my @array;
>
> while (<>) {
The above line needs to be:
while (<$fh>) {
> next unless /;/;
> chomp;
> my @data = ( split /;/ )[31,32,38,261];
> push @array, join "\t", @data;
> }
>
> @array = sort {
> my @aa = split /\t/, $a;
> my @bb = split /\t/, $b;
> $aa[0] <=> $bb[0] or
> $aa[1] <=> $bb[1] or
> $aa[2] <=> $bb[2];
> } @array;
>
> print $out "$_\n" foreach @array;
> close $out;
Can you get your email client to add "quoting" symbols to the beginning of
the lines that were in the message to which you are responding (like the '>
' in this message)? That would make it easier for people to tell what you
have written and what was written before.
Thanks.
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/