PageRenderTime 30ms CodeModel.GetById 25ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/tools/filters/headWrapper.pl

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