in reply to Re^3: Need help figuring out how to order/eval the numbers
in thread Need help figuring out how to order/eval the numbers
I am now stopped with my new test to implement new learnings...I read and reviewed other code and still lost...maybe I need a break or think of a better test prog to try out skills
need help here with doing a proper sub routine check on the values of a hash ref. while using the <=>
IF the value = value1 then print out to file
IF value of either is not the same then print those to a file
1 = 1 2 = 2 3 = 3 4 = 4 5 = 5
1 = 2 2 = 2 3 = 4 4 = 7 5 = 5 6 = 6
use strict; use warnings; use autodie; use diagnostics; use Data::Dump qw(dump); my %seen; open my $in,'<','./Test_Data.txt'; while(<$in>){ my ($key,$value)= split /[\s=\s]+/; $seen{$key}[0]=$value; } close $in; #using ONE hashes to check key open my $in1,'<','./Test_Data1.txt'; while(<$in1>){ my ($key,$value)= split /[\s=\s]+/; $seen{$key}[1]=$value if (exists $seen{$key}); } close $in1; #dump \%seen; #section uses as follows: ? conditional to write on different output f +iles #also, 1st sub to written by me... to check the values open my $out,'>','./OUT_test_data_keys_and_sorted_values_match.txt'; open my $out1,'>','./OUT_test_data_No_values_matched.txt'; foreach my $key ( sort { check_values()} keys %seen){ if ($key){ my $fh = defined $seen{$key}[0] && defined $seen{$key}[1] ? $out:$out1; print $fh "$key => ",join(',',@{$seen{$key}}),"\n"; } } close $out; close $out1; #here is first SUBROUTINE checks that value [0] == value[1] #my %number; sub check_values{ for my $key (sort {$a<=>$b} keys %seen){ #don't know how ,where to get valueat [0],value at[1] from??wh +o has the values? what is really (a and b) in, is it $_ or %seen? wha +t am I really evaluating with,is it like this: $seen{$key}[0]=$a or $ +seen{$key}[1]=$b...completely lost... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Need help figuring out how to order/eval the numbers
by roboticus (Chancellor) on Jun 25, 2015 at 02:23 UTC | |
by perlynewby (Scribe) on Jun 25, 2015 at 19:32 UTC | |
|
Re^5: Need help figuring out how to order/eval the numbers
by perlynewby (Scribe) on Jun 27, 2015 at 02:22 UTC |