Home: Perl Programming Help: Beginner:
Simple question...



steve
Deleted

Mar 30, 2000, 4:30 AM


Views: 2050
Simple question...

Hello,

What is the difference between calling a sub routine with the "&" and without?

What is the difference between this:
$variable = &name_sub_routine()

and this:
$variable = name_sub_routine()

Thanks,
Steve


japhy
Enthusiast

Mar 30, 2000, 5:00 AM


Views: 2050
Re: Simple question...

The 'perlsub' documentation does a better job of explaining this, but I will paraphrase.

1. function() -- if function() has prototypes, they will be honored

2. &function() -- prototypes are NOT honored

3. &function -- the same as saying &function(@_)

In most cases, you really don't need the & sign -- it's from Perl 4 code, most likely.