Advertisement
hakonhagland

extract-lines

May 27th, 2021
1,801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.36 KB | None | 0 0
  1. use strict;
  2. use warnings;
  3. my $fn = 'file.txt';
  4. open ( my $fh, '<', $fn ) or die "Could not open file '$fn': $!";
  5. my @array;
  6. while( ! (eof $fh) ) {
  7.     my $line1 = <$fh>;
  8.     my $line2 = <$fh>;
  9.     if ( defined $line2 ) {
  10.         chomp $line2;
  11.         $line2 =~ s/^>//;  # Remove leading ">" character
  12.         push @array, $line2;
  13.     }
  14. }
  15. close $fh;
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement