NAME

Bubblegum::Object::Scalar - Common Methods for Operating on Scalars

VERSION

version 0.35

SYNOPSIS

use Bubblegum;

my $variable = 12345;
say $variable->or(56789); # 12345

DESCRIPTION

Scalar methods work on data that meets the criteria for being a defined. It is not necessary to use this module as it is loaded automatically by the Bubblegum class.

METHODS

and

my $variable = 12345;
$variable->and(56789); # 56789

$variable = 0;
$variable->and(56789); # 0

The and method performs a short-circuit logical AND operation using the subject as the lvalue and the argument as the rvalue and returns the last truthy value or false.

not

my $variable = 0;
$variable->not; # 1

$variable = 1;
$variable->not; # ''

The not method performs a logical negation of the subject. It's the equivalent of using bang (!) and return true (1) or false (empty string).

or

my $variable = 12345;
$variable->or(56789); # 12345

$variable = 00000;
$variable->or(56789); # 56789

The or method performs a short-circuit logical OR operation using the subject as the lvalue and the argument as the rvalue and returns the first truthy value.

print

my $variable = 12345;
$variable->print(6789); # 123456789

$variable = 'yes';
$variable->print('no'); # yesno

The print method prints the scalar value to STDOUT, and returns true if successful.

repeat

my $variable = 12345;
$variable->repeat(2); # 1234512345

$variable = 'yes';
$variable->repeat(2); # yesyes

The repeat method returns a string consisting of the subject repeated the number of times specified by the argument.

say

my $variable = 12345;
$variable->say(6789); # 123456789\n

$variable = 'yes';
$variable->say('no'); # yesno\n

The say method prints the scalar value with a newline appended to STDOUT, and returns true if successful.

xor

my $variable = 1;
$variable->xor(1); # 0
$variable->xor(0); # 1

The xor method performs an exclusive OR operation using the subject as the lvalue and the argument as the rvalue and returns true if either but not both is true.

SEE ALSO

Bubblegum::Object::Array, Bubblegum::Object::Code, Bubblegum::Object::Hash, Bubblegum::Object::Instance, Bubblegum::Object::Integer, Bubblegum::Object::Number, Bubblegum::Object::Scalar, Bubblegum::Object::String, Bubblegum::Object::Undef, Bubblegum::Object::Universal,

AUTHOR

Al Newkirk <anewkirk@ana.io>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Al Newkirk.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.