#!/perl -w
# NAME: subref.pl
# AIM: To call a function, or set a global, by calling a function ...
use strict;
use warnings;
my $value1 = "<1 not set>";
my $value2 = "<2 not set>";
my ($valref, $serv);
sub set_value1 { $value1 = shift; }
sub set_value2 { $value2 = shift; }
sub type1 {
	my ($msg) = shift;
	prt( "Run TYPE1 ... $msg ...\n" );
}
sub type2 {
	my ($msg) = shift;
	prt( "Run TYPE2 ... $msg ...\n" );
}
my $test = 1;
if ($test == 1) {
	$serv = \&type1;
	$valref = \&set_value1;
} else {
	$serv = \&type2;
	$valref = \&set_value2;
}
$serv->( "This msg" );	# call the 'service', with value
$valref->( "IS SET" );	# set a global, with this value
prt( "value1 = $value1, value2 = $value2 ...\n" );

sub prt {
	my ($t) = shift;
	print $t;
}
# eof - subref.pl
