/tools/filters/headWrapper.pl

https://bitbucket.org/h_morita_dbcls/galaxy-central · Perl · 19 lines · 11 code · 5 blank · 3 comment · 2 complexity · 01cac2b965ea53fff978113e47fb61a3 MD5 · raw file

  1. #! /usr/bin/perl -w
  2. use strict;
  3. use warnings;
  4. # a wrapper for head for use in galaxy
  5. # headWrapper.pl [filename] [# lines to show] [output]
  6. die "Check arguments" unless @ARGV == 3;
  7. die "Line number must be an integer\n" unless $ARGV[1]=~ m/^\d+$/;
  8. open (OUT, ">$ARGV[2]") or die "Cannot create $ARGV[2]:$!\n";
  9. open (HEAD, "head -n $ARGV[1] $ARGV[0]|") or die "Cannot run head:$!\n";
  10. while (<HEAD>) {
  11. print OUT;
  12. }
  13. close OUT;
  14. close HEAD;