Created
May 21, 2017 17:37
-
-
Save andrewsolomon/39aa32e0d39a3fc458a234ec489f59be 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
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use feature 'say'; | |
use Data::Dump 'pp'; | |
my $INFO; | |
sub wantchecker { | |
if (wantarray) { | |
$INFO = 'you want an array'; | |
return ('this', 'is', 'a', 'list'); | |
} | |
if (defined(wantarray)) { | |
$INFO = 'you want a string'; | |
return 'this is a string'; | |
} | |
$INFO = 'you want nothing'; | |
} | |
my $str = wantchecker(); | |
say '$INFO = '.$INFO.' $str = '.$str; | |
my @arr = wantchecker(); | |
say '$INFO = '.$INFO.' @arr = '.pp(@arr); | |
my %hash = wantchecker(); | |
say '$INFO = '.$INFO.' %hash = '.pp(%hash); | |
wantchecker(); | |
say '$INFO = '.$INFO; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment