Option::Option
Provides objects that can hold results that can be unwrapped similar to Rust
use Option::Option; my $option = Option::Option->new("something"); # This croaks: print $var; # This works my $var = $option->unwrap(); print $var; # This also works and has a helpful error message my $var = $option->expect("get my something"); print $var;
Lee Katz
Creates a new object with a variable
Checks if the variable is defined and if it is, returns it. If not defined, croaks.
Checks if the variable is defined and if it is, returns it. If not defined, croaks with error message.
Dies with an error message, describing that the object was attempted to be used in a scalar context without unwrapping. This subroutine is not meant to be used directly.
my $var = Option::Option->new("something"); my $concat = $var . " wicked this way comes"; # dies with error message during the concatenation
To install Option::Option, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Option::Option
CPAN shell
perl -MCPAN -e shell install Option::Option
For more information on module installation, please visit the detailed CPAN module installation guide.