Skip to content

Commit

Permalink
show an example too
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 1, 2016
1 parent d79e37a commit bcf2943
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Mojo/Util.pm
Expand Up @@ -616,6 +616,10 @@ Extract options from an array reference with L<Getopt::Long>, but without
changing its global configuration. The configuration options C<no_auto_abbrev>
and C<no_ignore_case> are enabled by default.
# Extract "charset" option
getopt ['--charset', 'UTF-8'], 'charset=s' => \my $charset;
say $charset;
=head2 hmac_sha1_sum
my $checksum = hmac_sha1_sum $bytes, 'passw0rd';
Expand Down
2 changes: 2 additions & 0 deletions t/mojo/util.t
Expand Up @@ -116,6 +116,8 @@ $tree = [
is_deeply split_cookie_header($header), $tree, 'right result';

# getopt
getopt ['--charset', 'UTF-8'], 'c|charset=s' => \my $charset;
is $charset, 'UTF-8', 'right string';
my $array = ['-t', 'test', '-h', '--whatever', 'Whatever!', 'stuff'];
getopt $array, ['pass_through'], 't|test=s' => \my $test;
is $test, 'test', 'right string';
Expand Down

0 comments on commit bcf2943

Please sign in to comment.