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

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

Expand Messages
  • John J. Francini
    Subroutines needn t be defined before they are used. You can, if you want, pre-declare them to save a little time on the part of the compiler. It will find
    Message 1 of 5 , Feb 5, 2006
    • 0 Attachment
      Subroutines needn't be defined before they are used. You can, if you
      want, pre-declare them to save a little time on the part of the
      compiler. It will find them all anyway.

      Do you have the O'Reilly Perl book set (or the Perl CD library)?
      Highly recommended -- especially since the authors are usually DEEPLY
      involved in the development of Perl itself.

      John


      >At 10:22 PM 2/5/2006, you wrote:
      >>Using & means that it's a user defined subroutine. For example:
      >>
      >>&print is a user define print and will not use Perls print function.
      >>Also, if you don't specify the "&", subroutines must be defined before
      >>you make a call to it.
      >
      >Bobbie,
      > Thanks for the explanation.. And I do like what it does.. Nice way to
      >keep things straight..
      >
      >But the last bit has me confused.. I place my subroutines at the end of my
      >code.. So far my code works well and I have no trouble calling them from
      >within the program.. So am I assuming this is not what you mean in your
      >post about the subroutines must be defined before they are called??
      >
      >Thanks again for ya'lls time.. It's great having such wonderful shoulders
      >on which I can stand..
      >
      >flk k
      >
      >
      >
      >
      >Unsubscribing info is here:
      >http://help.yahoo.com/help/us/groups/groups-32.html
      >Yahoo! Groups Links
      >
      >
      >
      >

      --
      ----
      John Francini <mailto:francini@...>
      +---------------------------------------------------------------------------+
      | "I have come to the conclusion that one useless man is called a disgrace; |
      | that two are called a law firm; and that three or more become a Congress.|
      | And by God I have had _this_ Congress!" |
      | -- John Adams |
      +---------------------------------------------------------------------------+
    • 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 2 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.