diff options
author | dakkar <dakkar@thenautilus.net> | 2016-08-05 12:01:12 +0100 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2016-08-05 12:01:12 +0100 |
commit | 17d9443ee8d459794d90e4c38b04ba6ca4a93c3b (patch) | |
tree | 1f8e78994fcad0efdaa18b5314256b082926233c /dobble.pl | |
parent | silence "experimental" warnings (diff) | |
download | dobble-17d9443ee8d459794d90e4c38b04ba6ca4a93c3b.tar.gz dobble-17d9443ee8d459794d90e4c38b04ba6ca4a93c3b.tar.bz2 dobble-17d9443ee8d459794d90e4c38b04ba6ca4a93c3b.zip |
allow symbols on the command line
Diffstat (limited to 'dobble.pl')
-rwxr-xr-x | dobble.pl | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -124,8 +124,14 @@ package CardsTable { sub load_symbols($file) { return undef unless $file; - use Path::Tiny; - return [ path($file)->lines_utf8 ]; + require Path::Tiny; + return [ Path::Tiny::path($file)->lines_utf8 ]; +} + +sub split_symbols($string) { + return undef unless $string; + require Encode; + return [ split //, Encode::decode('utf-8',$string) ]; } use Getopt::Long::Descriptive; @@ -134,7 +140,8 @@ my ($opt,$usage) = describe_options( '%c %o', [ 'order|o=i', 'order of the finite field', { required => 1 } ], [ 'padding|p!', 'vertically align symbols', { default => 0 } ], - [ 'symbols|s=s', 'file with one symbol per line' ], + [ 'symbols|s=s', 'string of symbols (one per character)' ], + [ 'symbols-from|f=s', 'file with one symbol per line' ], [], ['help|h', 'show this help text', { shortcircuit => 1 } ], ); @@ -144,7 +151,10 @@ my $order = $opt->order; my $plane = FiniteProjectivePlane->new(mod=>$order); my $table = CardsTable->new( padding=>$opt->padding, - symbols => load_symbols($opt->symbols), + symbols => ( + split_symbols($opt->symbols) + || load_symbols($opt->symbols_from), + ), ); # sanity check |