Content of the perl file:
@array=("hello","aaaa","lll","ggg");
print "The content of array element 0 and 1 before function call is $array[0] and $array[1]"."\n";
function(@array);
print "The content of array element 0 and 1 after function call is $array[0] and $array[1]";
sub function()
{
$_[0]="Great";#this is the scalar reference of the first element in the array.
$_[1]="awesome";#this is the scalar reference of the second element in the array.
}
Output:
G:\perl_programs>perl perl_pass_by_reference.pl
The content of array element 0 and 1 befoe function call is hello and aaaa
The content of array element 0 and 1 after function call is Great and awesome
G:\perl_programs>
No comments:
Post a Comment