Last active
December 20, 2015 21:39
-
-
Save three18ti/6199085 to your computer and use it in GitHub Desktop.
Truth test perl
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 5.010; | |
%hash ? say "Empty Hash is true" : say "Empty Hash is false" ; | |
scalar keys %hash > 0 ? say "Empty Hash is true" : say "Empty Hash is false" ; | |
%hash = ( foo => 1, bar => 2 ); | |
%hash ? say "Hash is true" : say "Hash is false"; | |
scalar keys %hash > 0 ? say "Hash is true" : say "Hash is false" ; | |
my @array = (); | |
@array ? say "Empty Array is true" : say "Empty Array is false" ; | |
push @array, "foo", "bar", "baz"; | |
@array ? say "Array is true" : say "Array is false"; | |
my $hash_ref = {}; | |
$hash_ref ? say "Empty HashRef is true" : say "Empty HashRef is false" ; | |
$hash_ref = { foo => 1, bar => 2, baz => 3, }; | |
$hash_ref ? say "HashRef is true" : say "HashRef is false" ; | |
my $array_ref = (); | |
$array_ref ? say "Empty ArrayRef is true" : say "Empty ArrayRef is false" ; | |
push @$array_ref, "foo", "bar", "baz"; | |
$array_ref ? say "ArrayRef is true" : say "ArrayRef is false" ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment