On Tue, Dec 30, 2008 at 10:08, David Ehresmann <dehresm...@gmail.com> wrote:
> this works, thanks.  I thought you had to declare the function before
> you called it? That is not right?
snip

No, but there are some benefits to doing so.  For instance, if you
don't use parenthesis with calls to functions perl hasn't seen yet the
parser can become confused:

#!/usr/bin/perl

use strict;
use warnings;

local $\ = "\n";

print add_one 0; #perl thinks add_one is a file handle

print add_one(1); #perl thinks add_one is a function

sub add_one { shift() + 1 }

print add_one 2; #perl thinks add_one is a function


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to