Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Ampersand sign pre-fix on calling of a sub-routine

Expand Messages
  • merlyn@stonehenge.com
    ... Bobby My understanding of it is: Bobby If you are using & - placing the subroutines at the end of the file will Bobby work. Bobby If you don t use & -
    Message 1 of 5 , Feb 6, 2006
    • 0 Attachment
      >>>>> "Bobby" == Bobby Jafari <bobby.jafari@...> writes:

      Bobby> My understanding of it is:
      Bobby> If you are using & - placing the subroutines at the end of the file will
      Bobby> work.
      Bobby> If you don't use & - then you must define the subroutines first.


      later; # doesn't work
      later(); # works
      &later; # works
      &later(); # works
      sub later { }

      sub chomp { }
      chomp; # calls built-in chomp
      chomp(); # calls built-in chomp
      &chomp; # calls your chomp
      &chomp(); # calls your chomp

      So & identifies the word as a user-defined subroutine, as opposed to a
      bareword or a built-in. It's only necessary when it would be otherwise
      misinterpreted.

      --
      Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
      <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
      Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
      See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
    Your message has been successfully submitted and would be delivered to recipients shortly.