CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
when to use & to call subroutine

 



newbie
Deleted

Apr 22, 2000, 11:14 AM

Post #1 of 2 (538 views)
when to use & to call subroutine Can't Post

the & to call a function/subroutine. However, I generally leave it off and
it works OK.

Why/why is it optional and when is it required ?


Cure
User

Apr 22, 2000, 12:48 PM

Post #2 of 2 (538 views)
Re: when to use & to call subroutine [In reply to] Can't Post

Hi

in perl5 the & was made optional if it looks like a sub call with
parens. without parens it is a bareword and needs to be declared in
advance sothe compiler can parse it as a sub call.

in perl4 the only way to call a sub was with &. you can still use & in
perl5 for a bareword call like &foo but most prefer to do foo() these
days. so & is not needed except for some special cases


Cure

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives