2007/8/30, Amichai Teumim <[EMAIL PROTECTED]>: > 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. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/