"Passing Data" Please respond to the following:

Computer Science
Tutor: None Selected Time limit: 1 Day

  • Give an example of how you could send data to a subroutine. Do you expect the data to change or remain the same?
Jun 8th, 2015

Thank you for the opportunity to help you with your question!

There are several ways to do it (like most things in Perl). I personally do it like this:

sub mySubroutine

{

      #get passed arguments

       my($name, $age, $reflist) = @_;

       #get the array from the reference

            my @list=@{$reflist} ;

            #good to go

}

#you need to pass @list as reference so you put \@list , which is the reference  to the array

mySubroutine($name, $age, \@list) ;


This example is to pass the following variables to subroutine mySubroutine, $name, $age and then this multidimensional array:

$name="jennifer";
$age=100;

$list[0][0]="TEST NAME 2";
$list[0][1]="TEST GROUP 2";
$[0][2]=10;

$[1][0]="TEST NAME 2";
$[1][1]="TEST GROUP 2";
$[1][2]=2;
The data would be change after the passing  the data to the subroutine accroding to the data that is passed.

Please let me know if you need any clarification. I'm always happy to answer your questions.
Jun 13th, 2015

Did you know? You can earn $20 for every friend you invite to Studypool!
Click here to
Refer a Friend
...
Jun 8th, 2015
...
Jun 8th, 2015
Feb 23rd, 2017
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer