forked from creaktive/st
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
29 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,10 @@ GetOptions( | |
'format|fmt|f=s', | ||
'no-header|nh', | ||
'transverse-output|to', | ||
|
||
# error handling | ||
'quiet|q', | ||
'strict', | ||
|
||
'help|h', | ||
) or pod2usage(1); | ||
|
@@ -81,7 +84,12 @@ while (my $num = <>) { | |
| [0-9]* \. [0-9]+ E [+-]? [0-9]+ | ||
) | ||
$}x) { | ||
warn "Invalid number '$num'\n" unless $opt{quiet}; | ||
my $err = "Invalid value '$num' on input line $.\n"; | ||
if ($opt{strict}) { | ||
die $err; | ||
} elsif (!$opt{quiet}) { | ||
warn $err; | ||
} | ||
next; | ||
} | ||
|
||
|
@@ -268,7 +276,16 @@ The following options are available: | |
--no-header|nh # don't display header | ||
--transverse-output|to # output in multiple lines | ||
--quiet|q # silently skip invalid input | ||
=head2 ERROR HANDLING | ||
What happens if "st" finds non-numeric data? By default it will | ||
emit a warning, skip the current line and continue. | ||
You can change this behavior with the following options: | ||
--quiet|q # silently skip invalid input (no warning) | ||
--strict # interrupt process | ||
=head2 EXAMPLES | ||
|
@@ -286,14 +303,7 @@ The following options are available: | |
Nelson Ferraz L<<[email protected]>> | ||
=head1 CONTRIBUTORS | ||
imurray, who suggested a different algorithm for calculating variance. | ||
asgeirn, who suggested a input filter and helped to remove some | ||
warnings. | ||
gabeguz, who modified the script to make it more portable. | ||
=head1 CONTRIBUTING | ||
Send comments, suggestions and bug reports to: | ||
|
@@ -303,6 +313,15 @@ Or fork the code on github: | |
https://github.com/nferraz/st | ||
=head2 THANKS | ||
imurray, who suggested a different algorithm for calculating variance. | ||
asgeirn, who suggested a input filter and helped to remove some | ||
warnings. | ||
gabeguz, who modified the script to make it more portable. | ||
=head1 COPYRIGHT | ||
Copyright (c) 2013 Nelson Ferraz. | ||
|