M
maasha
G'day all,
In order to stream-line my scripts I would like to be able to read
data from either file(s) or a pipe, however, the way I do this results
in a lot of redundant code as shown in the below code snip. Somehow,
there must be a smarter way to do this!?!
Cheers,
M
if ( not -t STDIN )
{
$fh = &Common:ipe_open();
print &count_entries( $fh ) . "\n";
close $fh;
}
else
{
foreach $file ( @{ $args->{ "FILES" } } )
{
$fh = &Common::read_open( $file );
$count = &count_entries( $fh );
print join( "\t", $file, $count ), "\n";
close $fh;
$tot += $count;
}
}
In order to stream-line my scripts I would like to be able to read
data from either file(s) or a pipe, however, the way I do this results
in a lot of redundant code as shown in the below code snip. Somehow,
there must be a smarter way to do this!?!
Cheers,
M
if ( not -t STDIN )
{
$fh = &Common:ipe_open();
print &count_entries( $fh ) . "\n";
close $fh;
}
else
{
foreach $file ( @{ $args->{ "FILES" } } )
{
$fh = &Common::read_open( $file );
$count = &count_entries( $fh );
print join( "\t", $file, $count ), "\n";
close $fh;
$tot += $count;
}
}