CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [Laurent_R] Modify script to compare and flag lists: Edit Log



stuckinarut
User

Jun 10, 2014, 12:20 PM


Views: 43129
Re: [Laurent_R] Modify script to compare and flag lists

Laurent:

Thanks for your post. It seems then Bill was then correct by separately loading in the 3 files as per his code offering.

I've chewed on this backwards and forwards and yet can't figure out how to get the final part to work with the $keys.


Code
#!/usr/bin/perl 
use strict;
use warnings;
my %H_list;
do {
open my $H_list, '<', 'listH.txt' or die "Cannot open xxxH.txt: $!";
my @temp = <$H_list>;
close $H_list;
@H_list{@temp} = 1 x scalar @temp;
};
my %A_list;
do {
open my $A_list, '<', 'listA.txt' or die "Cannot open xxxA.txt: $!";
my @temp = <$A_list>;
close $A_list;
@A_list{@temp} = 1 x scalar @temp;
};
open my $L_list, '<', 'listL.txt' or die "Cannot open xxxL.txt: $!";
while (<$L_list>) {
chomp;
print;
# print ' H' if exists $H_list{$_};
# print ' A' if exists $A_list{$_};
# The above 2 lines yield no flags
# Some variation of this code *should* work but can't figure out how to fix it ;-(
for my $key ( sort { ($L_list{$_})[0] cmp ( ($H_list{$_})[0] || ($A_list{$_})[0]) ) } keys %hash ) {
print $key if exists $hash{$key}{$L_list{$_}};
print ' H' if keys %{ $hash{$key}{$H_list{$_}} } == 2;
print ' A' if keys %{ $hash{$key}{$A_list{$_}} } == 2;
print "\n";
}
}


Frustrating beyond belief !

- stuckinarut


(This post was edited by stuckinarut on Jun 10, 2014, 12:52 PM)


Edit Log:
Post edited by stuckinarut (User) on Jun 10, 2014, 12:21 PM
Post edited by stuckinarut (User) on Jun 10, 2014, 12:22 PM
Post edited by stuckinarut (User) on Jun 10, 2014, 12:52 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives