/tools/filters/remove_beginning.pl

https://bitbucket.org/h_morita_dbcls/galaxy-central · Perl · 33 lines · 22 code · 8 blank · 3 comment · 3 complexity · 690f6f4c143a2bbdf97f5f3a69285f63 MD5 · raw file

  1. #! /usr/bin/perl -w
  2. use strict;
  3. use warnings;
  4. # Removes the specified number of lines from the beginning of the file.
  5. # remove_beginning.pl [input] [num_lines] [output]
  6. die "Check arguments" unless @ARGV == 3;
  7. my $inputfile = $ARGV[0];
  8. my $num_lines = $ARGV[1];
  9. my $outputfile = $ARGV[2];
  10. my $curCount=0;
  11. my $fhIn;
  12. open ($fhIn, "< $inputfile") or die "Cannot open source file";
  13. my $fhOut;
  14. open ($fhOut, "> $outputfile");
  15. while (<$fhIn>)
  16. {
  17. $curCount++;
  18. if ($curCount<=$num_lines)
  19. {
  20. next;
  21. }
  22. print $fhOut $_;
  23. }
  24. close ($fhIn) or die "Cannot close source file";
  25. close ($fhOut) or die "Cannot close output file";