>>>>> "PJ" == Paul Johnson <p...@pjcj.net> writes:
>> 2,1,1,1175,2.58522727272727,1 >> 2,1,1,1175,, >> 2,1,1,1175,1.35416666666667,1 >> 2,1,1,1175,1.82765151515152,1 >> 2,1,1,1175,, >> 2,2,1,1175,, >> 8,1,1,1175,, >> 10,2,1,1175,0.710227272727273,1 that is his output from MY version of the program, not input. >> use File::Slurp; >> >> my $filepath = 'C:/temp/PCMD'; >> my $output = 'output.txt'; >> >> my %cols = ( >> cell => 31, >> sect => 32, >> chan => 38, >> dist => 261, >> precis => 262, >> ); PJ> These values don't match the data you have above. Do you really have PJ> 262 items of data per line? yes, he does. please follow the whole thread. >> next unless $line =~ /;/; PJ> Your data is separated by commas, not semicolons. again, follow the whole thread. yes, he put his output at the top. >> $record{dist} = ( length( $record{dist}) > 1 ) ? $record{dist}/6.6/8/2*10/10 : '' ; PJ> This seems strange. it is a wacky expression but legal and seemingly what he wants. >> >> printf '<%.2g>', @report ; >> #print @report ; >> write_file($output, @report) ; PJ> And this bit is just wrong. which bit? the write_file is perfectly fine. the printf is very wrong. and i posted about it already. again (you like that word), please follow the thread and don't jump in the middle. PJ> my %cols = ( PJ> cell => 0, PJ> sect => 1, PJ> chan => 2, PJ> dist => 3, PJ> precis => 4, PJ> ); wrong. PJ> my @records; PJ> open my $fh, "<$filepath"; PJ> while (my $line = <$fh>) { PJ> next unless $line =~ /,/; wrong. PJ> my %record; PJ> # this gets just what you want into a hash using a hash slice and an # array slice. PJ> # the order of keys and values will be the same for any # given hash PJ> @record{ keys %cols } = (split /,/, $line)[ values %cols ]; wrong. PJ> for my $s (@sorted) { PJ> printf "<%.2g>", $s->{$_} for qw(cell sect carr chan dist precis); wrong. he wants output to the screen and also to a file. uri -- Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/