PERL   70

print file 2

Guest on 16th August 2022 01:15:49 AM

  1. #!/usr/local/bin/perl
  2.  
  3. open(FILE,"foo.dat");
  4.  
  5. while(<FILE>) {
  6.   chomp;
  7.   if ($_ ne "") {
  8.     ($last,$first,$email) = split /::/;
  9.     $firstnames{$last} = $first;
  10.     $emails{$last} = $email;
  11.   }
  12. }
  13.  
  14. foreach $key (sort(keys %firstnames)) {
  15.   print "$firstnames{$key} $key\'s email is $emails{$key}\n";
  16. }

Raw Paste


Login or Register to edit or fork this paste. It's free.