summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdobble.pl18
1 files changed, 14 insertions, 4 deletions
diff --git a/dobble.pl b/dobble.pl
index 5040d7a..324b3cd 100755
--- a/dobble.pl
+++ b/dobble.pl
@@ -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