Re: marine subroutine
- From: rwwebs@xxxxxxxxx (Jeff Pang)
- Date: Thu, 30 Aug 2007 15:43:54 +0800
2007/8/30, Amichai Teumim <amichai@xxxxxxxxxx>:
Hi
I'm trying to understand subroutines.
#!/usr/bin/perl
&marine()
sub marine {
$n += 1; #Global variable $n
print "Hello, sailor number $n!\n";
}
This doesn't work. Is &marine() incorrect? How would I call the sub marine?
Because you lost a ';' after &marine().
Also from perldoc perlsub,
To call subroutines:
NAME(LIST); # & is optional with parentheses.
NAME LIST; # Parentheses optional if predeclared/imported.
&NAME(LIST); # Circumvent prototypes.
&NAME; # Makes current @_ visible to called subroutine.
.
- Follow-Ups:
- Re: marine subroutine
- From: Martin Barth
- Re: marine subroutine
- References:
- marine subroutine
- From: Amichai Teumim
- marine subroutine
- Prev by Date: marine subroutine
- Next by Date: Re: marine subroutine
- Previous by thread: marine subroutine
- Next by thread: Re: marine subroutine
- Index(es):
Relevant Pages
|
|