Guest User

Untitled

a guest
Dec 11th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.10 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. open LIST1, "list1.txt" or die $!;
  4. open LIST2, "list2.txt" or die $!;
  5. open LIST3, "list3.txt" or die $!;
  6.  
  7. $list1 = {};
  8. $list2 = {};
  9. $list3 = {};
  10.  
  11. while (<LIST1>) {
  12.    $rec = {};
  13.    ($num, $name, $position, $department) = split(/, /, $_);
  14.     chomp($department);
  15.     $rec->{"name"} = $name;
  16.     $rec->{"position"} = $position;
  17.     $rec->{"department"} = $department;
  18.    $list1{$num} = $rec;
  19. }
  20.  
  21. while (<LIST2>) {
  22.    $rec = {};
  23.    ($name, $num, $address, $tel_no, $ss_no) = split(/, /, $_);
  24.     $rec->{"name"} = $name;
  25.     $rec->{"address"} = $address;
  26.     $rec->{"tel_no"} = $tel_no;
  27.     $rec->{"ss_no"} = $ss_no;
  28.    $list2{$num} = $rec;
  29. }
  30.  
  31. while (<LIST3>) {
  32.    $rec = {};
  33.    ($num, $ss_no, $salary) = split(/, /, $_);
  34.     $rec->{"ss_no"} = $ss_no;
  35.     $rec->{"salary"} = $salary;
  36.    $list3{$num} = $rec;
  37. }
  38.  
  39. foreach $num ( %list3 ) {
  40.    if ($list3{$num}{"salary"} > 2000) {
  41.       print "Name: ".$list1{$num}{"name"}."\n";
  42.       print "Address: ".$list2{$num}{"address"}."\n";
  43.       print "Department: ".$list1{$num}{"department"}."\n";
  44.       print "Salary: £".$list3{$num}{"salary"}."\n";
  45.    }
  46. }
Add Comment
Please, Sign In to add comment