nillbug

Untitled

May 10th, 2014
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #!usr/bin/perl -w
  2. #William Whitehead
  3. #$date
  4. #Engr 212
  5.  
  6. my $in_file = 'cn.txt';
  7. open my $in_fh, '<', $in_file or die "Could not open file $in_file: $!";
  8.  
  9. my $out_file = 'liboutput.txt';
  10. open my $out_fh, '>', $out_file or die "Could not open file $out_file: $!";
  11.  
  12. while ( my $line = <$in_fh> ) {
  13. print {$out_fh} $line if $line =~ /\|LIB\|/;
  14. }
  15.  
  16. close $in_fh or die "Could not close file $in_file: $!";
  17. close $out_fh or die "Could not close file $out_file: $!";
  18.  
  19. my $in_file = 'liboutput.txt';
  20. open my $in_fh, '<', $in_file or die "Could not open file $in_file: $!";
  21.  
  22. my $out_file = 'caoutput.txt';
  23. open my $out_fh, '>', $out_file or die "Could not open file $out_file: $!";
  24.  
  25. while ( my $line = <$in_fh> ) {
  26. print {$out_fh} $line if $line =~ /\|CA\|H\|/;
  27. }
  28.  
  29. close $in_fh or die "Could not close file $in_file: $!";
  30. close $out_fh or die "Could not close file $out_file: $!";
  31.  
  32. open (FILE, 'caoutput.txt');
  33. while (<FILE>) {
  34. chomp;
  35. ($id, $name, $party, $year, $state, $office, $district, $status1, $status2, $pcc, $address, $address2, $city, $state, $zip) = split(/\|/);
  36. print "Name: $name\n";
  37. print "Address: $address\, $address2$city\, $state $zip \n";
  38. print "---------\n";
  39. }
  40. close (FILE);
  41. exit;
Advertisement
Add Comment
Please, Sign In to add comment