Skip to content

Instantly share code, notes, and snippets.

@k-ohtani-is-deleting
Created July 31, 2012 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k-ohtani-is-deleting/3212583 to your computer and use it in GitHub Desktop.
Save k-ohtani-is-deleting/3212583 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use Test::More qw/no_plan/;
my $key = '1,2,';
my ($a1, $a2, $a3) = split /,/o, $key;
is($a1, '1');
is($a2, '2');
is($a3, '');
my @keys = split /,/o, $key;
is(scalar @keys, 2);
my ($b1, $b2, $b3) = @keys;
is($b1, '1');
is($b2, '2');
is($b3, undef);
sub parse_key { map { $_ || '' } split /,/o, shift }
my @keys2 = parse_key($key);
is(scalar @keys2, 2);
my($c1, $c2, $c3) = parse_key($key);
is($c1, '1');
is($c2, '2');
is($c3, undef);
ok(1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment