lvalue - use lvalue subroutines with ease


lvalue documentation  | view source Contained in the lvalue distribution.

Index


VERSION

Top

Version 0.01

SYNOPSIS

Top

Simply put get and set blocks at the end of your lvalue sub. Please note, no comma or semicolon between statements are allowed (in case of semicolon only last statement will be take an action)

	use lvalue;

	sub mysub : lvalue {
		get {
			return 'result for get';
		}
		set {
			my $set_value = shift;
			# ...
		}
	}

	mysub() = 'test'; # will invoke set block with argument 'test';
	print mysub(); # will invoke get block without arguments. result will be returned to print;

	sub readonly : lvalue {
		get {
			return 'readonly value';
		}
	}

	print readonly();  # ok
	readonly = 'test'; # fails

	sub writeonly : lvalue {
		set {
			my $set_value = shift;
			# ...
		}
	}

	writeonly = 'test'; # ok
	print writeonly();  # fails

EXPORT

Top

There are 2 export functions: set and get. If you don't want to use export, you may use full names

	sub mysub : lvalue {
		lvalue::get {
			return 'something';
		}
		lvalue::set {
			my $set_value = shift;
		}
	}

FUNCTIONS

Top

set

invoked with argument from right side

get

invoked without arguments. the returned value passed out

AUTHOR

Top

Mons Anderson, <mons@cpan.org>

BUGS

Top

None known

COPYRIGHT & LICENSE

Top


lvalue documentation  | view source Contained in the lvalue distribution.