Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions bin/st
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ GetOptions(
'complete|all',
'default|basic',

# input control
'comma|c=s',

# output control
'delimiter|d=s',
'format|fmt|f=s',
Expand All @@ -48,7 +51,6 @@ pod2usage(1) if $opt{help};
my %config = get_config(%opt);

my %result = process(%opt);

my @opt = grep { defined $result{$_} } statistical_options(%opt);

if (scalar @opt == 1) {
Expand Down Expand Up @@ -119,8 +121,31 @@ sub process {

my $M2 = 0; # used to calculate variance


while (my $num = <>) {
my $inputdelimiter = $opt{'comma'};
my @element_arr;
my $interator;

if ($inputdelimiter) {
$interator = sub {
unless (scalar @element_arr) {
my $line = <>;
if ($line) {
@element_arr = split($inputdelimiter , $line);
}
else { return 0; } #if no line done with all files
}
my $element = shift @element_arr;
$element =~ s/^\s+//;
$element =~ s/\s+$//;
return $element;
}
}
else {
$interator = sub { my $line = <>; return $line; }
}


while (my $num = $interator->()) {
chomp $num;

if (!valid_input($num)) {
Expand Down Expand Up @@ -314,6 +339,10 @@ If no functions are selected, C<st> will print:

n min max sum mean sd

=head3 INPUT FORMATTING

--comma|-c=<value> #default: "\n"

=head3 FORMATTING

--delimiter|d=<value> # default: "\t"
Expand Down