Skip to content

Instantly share code, notes, and snippets.

@jef-sure
Created February 26, 2018 18:59
Show Gist options
  • Select an option

  • Save jef-sure/8d3487e8a84fe795ca6458b6e6f51222 to your computer and use it in GitHub Desktop.

Select an option

Save jef-sure/8d3487e8a84fe795ca6458b6e6f51222 to your computer and use it in GitHub Desktop.
package Undef;
sub new { bless \my $a, $_[0] }
sub AUTOLOAD { Undef->new }
use overload
'""' => sub {""},
lt => sub { $_[2] ? $_[1] lt "" : "" lt $_[1] },
le => sub { $_[2] ? $_[1] le "" : "" le $_[1] },
gt => sub { $_[2] ? $_[1] gt "" : "" gt $_[1] },
ge => sub { $_[2] ? $_[1] ge "" : "" ge $_[1] },
eq => sub { "" eq $_[1] },
ne => sub { "" ne $_[1] },
bool => sub { 0 == 1 },
'0+' => sub {undef};
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment