Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: outputing specific co-ordinates

by Khen1950fx (Canon)
on Nov 19, 2011 at 12:01 UTC ( #938963=note: print w/replies, xml ) Need Help??

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.
#!/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

    Many thanks for your response I'm just wondering how this differs from the first script will i get the same output?

      sorry forgot to log in!

        The main difference is that I used a hash. The output was the same using 5.8.8, 5.10.1, and 5.14.1.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://938963]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2018-03-17 11:17 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (223 votes). Check out past polls.