Created
July 31, 2012 01:35
-
-
Save k-ohtani-is-deleting/3212583 to your computer and use it in GitHub Desktop.
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
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