From: "Mr. Shawn H. Corey" <shawnhco...@magma.ca>
> On Tue, 2008-12-30 at 07:10 -0600, David Ehresmann wrote:
> > fact();
> 
> This calls the sub with an undef arguement.  Just delete this line.

No. It calls the sub with no arguments.

fact(undef);

would call it with an undef argument.
 
> > my $num;
> > 
> > print "enter a number: \n";
> > chomp($num = <STDIN>);
> > 
> > my $x = fact($num);
> > print "the factorial is: $x\n";
> > 
> > sub fact {
> >         my $num = 0;
> >         $num = shift;
> 
> Can be done in one line :  my $num = shift @_;

Just to prevent confusion ... within a sub{} the

 $num = shift;
and
 $num = shift @_;

are equivalent.

Jenda
===== je...@krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
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