Created
July 17, 2013 14:20
-
-
Save pdl/6020967 to your computer and use it in GitHub Desktop.
Demonstrate simple function to return the first item in an array if called in scalar context.
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
#!perl | |
use strict; | |
use warnings; | |
use Test::More; | |
sub first_or_all { | |
return @_ if wantarray; | |
return shift; | |
} | |
sub lowercase { | |
return first_or_all ( map { lc } @_ ); | |
} | |
is (lowercase('Jim'), 'jim' ); | |
is_deeply ([lowercase('Jim', 'Angela')], ['jim','angela'] ); | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment