SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: basic query

  1. #1
    SitePoint Evangelist priti's Avatar
    Join Date
    Aug 2006
    Location
    India
    Posts
    488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    basic query

    hi all,

    I just wanted to clear my confusion about a very basic thing. When you call subroutine in perl i have seen people using two ways.

    sub_name()
    &sub_name()

    how there two routine call differs i mean when one will use & to call function in perl.

    Kindly clarify.

    Regards

  2. #2
    SitePoint Wizard bronze trophy KevinR's Avatar
    Join Date
    Nov 2004
    Location
    Moon Base Alpha
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    While there are differences in the two methods, for the most part you can ignore them. But if you are interested it is explained in perlsub. The explanation is pretty technical however and unless you understand about references, @_, and prototypes, it may not make much sense.

    http://perldoc.perl.org/perlsub.html

    The recommended way with any modern perl version (not sure about perl 6 though) is all lowercase with parenthesis:

    foo()


    mixed case with parenthesis is very common:

    FooBar()

    what to avoid:

    all lowercase no parenthesis:

    foo (for builtin perl functions and keywords and such)

    all uppercase no parenthesis:

    FOO (for special code blocks, like BEGIN, maybe other things too)

  3. #3
    SitePoint Evangelist priti's Avatar
    Join Date
    Aug 2006
    Location
    India
    Posts
    488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •