chorg has asked for the wisdom of the Perl Monks concerning the following question:

Ex:

while($sth->fetch) { # Code here }
This works in the DBI, although there is no parens in the code, and in the module there is nothing special about it. So my question is: Under what circumstances can I do this?
_______________________________________________
"Intelligence is a tool used achieve goals, however goals are not always chosen wisely..."

Replies are listed 'Best First'.
Re: When can I skip parens?
by chromatic (Archbishop) on Nov 23, 2000 at 04:07 UTC
    You can use bare function names when the functions have been predefined. It's okay in this snippet:
    sub action { print "Action!"; } action;
    but not in this one:
    action; # error under strict and -w sub action { print "Action!"; }
    Using the parenthesis makes a bare word unambiguous -- as a function. (see page 677 of the new Camel)

    Update: My explanation is a little ambiguous. When you use the DBI module, it's loaded, compiled, and the functions it exports are imported into your namespace at that location in your file. All of its functions are effectively predeclared. Make sense?

(tye)Re1: When can I skip parens?
by tye (Sage) on Nov 23, 2000 at 09:54 UTC