# First, let me say thank you in advance for your time.
# I've spent over three hours digging, reading,
# searching, experimenting so far and #am frustrated.
# I am still (obviously) in the first few weeks of my
# perl experiance. I have written many programs in C,
# C++ and VB .NET and I KNOW, that there must be a way
# to pass a parameter to a function BY REFERENCE
# (i.e. changing the parameter's value in the function)
# THE CURRENT OUTPUT
myVal_1 = Original Val_1, myVal_2 = Original Val_2, myVal_3 = Original Val_3
myVal_1 = Original Val_1, myVal_2 = Original Val_2, myVal_3 = Original Val_3
myVal_1 = Original Val_1, myVal_2 = Original Val_2, myVal_3 = Original Val_3
# THE DESIRED OUTPUT
myVal_1 = Original Val_1, myVal_2 = Original Val_2, myVal_3 = Original Val_3
myVal_1 = New Value 1, myVal_2 = New Value 2, myVal_3 = New Value 3
# THE PROGRAM AS IT STANDS
Main();
sub Main
{
my $myMainVal_1 = "Original Val_1";
my $myMainVal_2 = "Original Val_2";
my $myMainVal_3 = "Original Val_3";
PrintVals($myMainVal_1,$myMainVal_2,$myMainVal_3);
ChangeVals($myMainVal_1,$myMainVal_2,$myMainVal_3);
PrintVals($myMainVal_1,$myMainVal_2,$myMainVal_3);
ChangeVals(\$myMainVal_1,\$myMainVal_2,\$myMainVal_3); # I thought this was the syntax for
# passing by reference, but same result
PrintVals($myMainVal_1,$myMainVal_2,$myMainVal_3);
print("end, placeholder for breakpooint");
}
sub ChangeVals
{
my $myVal_1 = shift;
my $myVal_2 = shift;
my $myVal_3 = shift;
$myVal_1 = "New Value 1";
$myVal_2 = "New Value 2";
$myVal_3 = "New Value 3";
}
sub PrintVals
{
my $myVal_1 = shift;
my $myVal_2 = shift;
my $myVal_3 = shift;
print ("myVal_1 = $myVal_1, myVal_2 = $myVal_2, myVal_3 = $myVal_3 ");
}
# I've spent over three hours digging, reading,
# searching, experimenting so far and #am frustrated.
# I am still (obviously) in the first few weeks of my
# perl experiance. I have written many programs in C,
# C++ and VB .NET and I KNOW, that there must be a way
# to pass a parameter to a function BY REFERENCE
# (i.e. changing the parameter's value in the function)
# THE CURRENT OUTPUT
myVal_1 = Original Val_1, myVal_2 = Original Val_2, myVal_3 = Original Val_3
myVal_1 = Original Val_1, myVal_2 = Original Val_2, myVal_3 = Original Val_3
myVal_1 = Original Val_1, myVal_2 = Original Val_2, myVal_3 = Original Val_3
# THE DESIRED OUTPUT
myVal_1 = Original Val_1, myVal_2 = Original Val_2, myVal_3 = Original Val_3
myVal_1 = New Value 1, myVal_2 = New Value 2, myVal_3 = New Value 3
# THE PROGRAM AS IT STANDS
Main();
sub Main
{
my $myMainVal_1 = "Original Val_1";
my $myMainVal_2 = "Original Val_2";
my $myMainVal_3 = "Original Val_3";
PrintVals($myMainVal_1,$myMainVal_2,$myMainVal_3);
ChangeVals($myMainVal_1,$myMainVal_2,$myMainVal_3);
PrintVals($myMainVal_1,$myMainVal_2,$myMainVal_3);
ChangeVals(\$myMainVal_1,\$myMainVal_2,\$myMainVal_3); # I thought this was the syntax for
# passing by reference, but same result
PrintVals($myMainVal_1,$myMainVal_2,$myMainVal_3);
print("end, placeholder for breakpooint");
}
sub ChangeVals
{
my $myVal_1 = shift;
my $myVal_2 = shift;
my $myVal_3 = shift;
$myVal_1 = "New Value 1";
$myVal_2 = "New Value 2";
$myVal_3 = "New Value 3";
}
sub PrintVals
{
my $myVal_1 = shift;
my $myVal_2 = shift;
my $myVal_3 = shift;
print ("myVal_1 = $myVal_1, myVal_2 = $myVal_2, myVal_3 = $myVal_3 ");
}