in reply to outputing specific co-ordinates
There's no need to use no warnings 'uninitialized';---just initialize the array. Remember, too, that the 1st arg to each must be a hash.
I tried your script in a slightly different way. I used a hash because I wanted to keep each.Outputs:#!/usr/perl/bin/perl use Modern::Perl; $|=1; my($data) = '/root/Desktop/inputfile.txt'; open STDIN, '<', $data or die "File error: input file: $!"; open STDOUT, '>', '/root/Desktop/output.log' or die "File error: output file: $!"; my(%result) = (); while (defined($_ = <STDIN>)) { chomp $_; my ($index, $value) = split( /\s/, $_, 0 ); $result{$index} = $value; } while (my ($index, $value) = each(%result)) { do { say "$index => $value" if $value > 500; }; } close STDIN; close STDOUT;
5 => 550
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: outputing specific co-ordinates
by Not_a_Number (Prior) on Nov 19, 2011 at 13:01 UTC | |
|
Re^2: outputing specific co-ordinates
by Anonymous Monk on Nov 19, 2011 at 13:06 UTC | |
by Taylorswift13 (Novice) on Nov 19, 2011 at 13:07 UTC | |
by Khen1950fx (Canon) on Nov 19, 2011 at 13:53 UTC |