Skip to content

Instantly share code, notes, and snippets.

@andrewsolomon
Created May 21, 2017 17:37
Show Gist options
  • Save andrewsolomon/39aa32e0d39a3fc458a234ec489f59be to your computer and use it in GitHub Desktop.
Save andrewsolomon/39aa32e0d39a3fc458a234ec489f59be to your computer and use it in GitHub Desktop.
#!/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