HesitantRhino Wiki : PerlSubroutines

HomePage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register
Subroutines in Perl are declared as follows...

sub sayhello {
  print "Hello";
}

/* calls to a subroutine */

sayhello();

&sayhello();


When you want to call (execute) a subroutine, there are two ways you may do so...

  1. Call the name of the subroutine as-is.
  2. Call the name of the subroutine, with an ampersand in the front.

Our recommendation? Get in the habit of using the ampersand.

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.3
Page was generated in 0.1458 seconds