[Bio] / FigKernelScripts / p3-head.pl Repository:
ViewVC logotype

Annotation of /FigKernelScripts/p3-head.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download) (as text)

1 : parrello 1.1 =head1 Return First Few Lines of the Input File
2 :    
3 :     p3-head.pl [options]
4 :    
5 :     This script returns the header line plus the first few data lines of the standard input stream. It is similar to the Unix B<head>
6 :     command, but works on Windows.
7 :    
8 :     =head2 Parameters
9 :    
10 :     There are no positional parameters.
11 :    
12 :     The standard input can be overridden using the options in L<P3Utils/ih_options>.
13 :    
14 :     Additional command-line options are as follows.
15 :    
16 :     =over 4
17 :    
18 :     =item nohead
19 :    
20 :     The file has no headers.
21 :    
22 :     =item lines
23 :    
24 :     The number of data lines to display. If there is a header line, it is not counted in this number. The default is C<10>.
25 :    
26 :     =back
27 :    
28 :     =cut
29 :    
30 :     use strict;
31 :     use P3DataAPI;
32 :     use P3Utils;
33 :    
34 :    
35 :     # Get the command-line options.
36 :     my $opt = P3Utils::script_opts('', P3Utils::ih_options(),
37 :     ['nohead', 'file has no headers'],
38 :     ['lines|n=i', 'number of data lines to display', { default => 10 }]
39 :     );
40 :     # Open the input file.
41 :     my $ih = P3Utils::ih($opt);
42 :     # Read the incoming headers.
43 :     my ($outHeaders) = P3Utils::process_headers($ih, $opt, 1);
44 :     # Echo the headers.
45 :     if (! $opt->nohead) {
46 :     P3Utils::print_cols($outHeaders);
47 :     }
48 :     # Compute the number of lines to print.
49 :     my $count = $opt->lines;
50 :     # Loop through the input.
51 :     while (! eof $ih && $count) {
52 :     my $line = <$ih>;
53 :     $count--;
54 :     print $line;
55 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3