Search

JAVA programming assignment 2

Copy this Storyboard
JAVA programming assignment 2

Storyboard Text

  • Don’t worry bestie, I gottchu. A Subroutine in Perl can be defined as a code of block that will perform a specific task by reusing the code. So, the user puts the section of code in subroutine so that there will be no need to write code again and again which is time consuming and unproductive.
  • OMGGG LEONARD!! What should I do!! My lecturer just told me to present on what is Subroutine in PERL. But I am not sure what it is!!
  • Oh, I see, so the syntax for Perl Subroutine is for the user to define the subroutine first by
  • Then Perl will call the defined subroutine by passing a list of arguments which can be as follow
  • ...so, I guess there will be a parameter of the syntax for the subroutine, right?
  • Yes, that is correct Michelle. The parameter included are Subroutine Name, Statement, Return and Argument List.
  • Did you know that there are in general four ways to implement subroutine in Perl. It can be done by Passing Arguments to Subroutine, Passing List to Subroutine, Passing Hashes to Subroutine, and Returning Value of a Subroutine.
  • Yes, an example for Passing Arguments to Subroutine would besub Display_hash {my (%hash_var) = @_;foreach my $key (keys %hash_var ){ my $val = $hash_var{$key}; print $key : $val\n}}%hash_para = ('Subject' = 'Perl', 'Marks' = 97);Display_hash(%hash_para); With the output of Marks : 97Subject : Perl
  • OOOOKAYY, so from this PowerPoint the expected result from this Passing Argument to Subroutine by applying Bioinformatics elements into it, we will get AAACGC for the result. The arguments 'AAA' and 'CGC' are passed into the subroutine as a list of scalars. The first statement in the subroutine's block which is my($dna1, $dna2) = @_;
  • subs concatenated DNA{my ($dna1, $dna2) = @_. my($concatenation);$concatenation = $dna1$dna2;return $concatenation.}print concatenated ('AAA', 'CGC');
  • Okay thank you for the wonderful presentation, Michelle. Moving onto another example of this another subroutine in Perl is the Passing List to Subroutine
  • sub sub_PrintList {my @sub_list = @_;}print Given list @sub_list\n;@q = (2, 3, 4, 5, 6, 7, 8, 9, 10);$p = 1;sub_PrintList($p, @q);OUTPUT: Given List 1 2 3 4 5 6 7 8 9 10
Over 30 Million Storyboards Created
No Downloads, No Credit Card, and No Login Needed to Try!
Storyboard That Family