Skip to content

Instantly share code, notes, and snippets.

@Meettya
Created December 2, 2011 16:04
Show Gist options
  • Save Meettya/1423764 to your computer and use it in GitHub Desktop.
Save Meettya/1423764 to your computer and use it in GitHub Desktop.
Default setter for undefined return
#!/usr/bin/env perl
use v5.14;
use warnings;
# develop mode
use Smart::Comments;
use Data::Printer;
sub some_function{
return shift == 1 ? 1 : undef;
}
foreach(0..1){
my $value = some_function($_);
$value //= 'default_value';
p($value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment