RE: marine subroutine
- From: andrew.curry@xxxxxxxxxxxx (Andrew Curry)
- Date: Thu, 30 Aug 2007 15:39:14 +0100
That's rubbish,
You can call a sub before you create it as you say. At compile time the
entire code is done (bar some exceptions)
The issue here is drop the & unless you really know what it does
my($n);
marine();
sub marine {
$n += 1;
print "Hello, sailor number $n!\n";
}
Works fine.
-----Original Message-----
From: anders [mailto:anders.u.persson@xxxxxxxxx]
Sent: 30 August 2007 09:18
To: beginners@xxxxxxxx
Subject: Re: marine subroutine
On 30 Aug, 09:39, amic...@xxxxxxxxxx (Amichai Teumim) wrote:
Himarine?
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
Thanks
Amichai
You can't use somting BEFORE you have created it try to call and call sub
with name and () and ;
sub marine {
$n += 1; #Global variable $n
print "Hello, sailor number $n!\n";
marine();
--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx For additional
commands, e-mail: beginners-help@xxxxxxxx http://learn.perl.org/
This e-mail is from the PA Group. For more information, see
www.thepagroup.com.
This e-mail may contain confidential information. Only the addressee is
permitted to read, copy, distribute or otherwise use this email or any
attachments. If you have received it in error, please contact the sender
immediately. Any opinion expressed in this e-mail is personal to the sender
and may not reflect the opinion of the PA Group.
Any e-mail reply to this address may be subject to interception or
monitoring for operational reasons or for lawful business practices.
.
- Follow-Ups:
- Re: marine subroutine
- From: Martin Barth
- Re: marine subroutine
- Prev by Date: Re: Logging STDERR and other output
- Next by Date: Re: marine subroutine
- Previous by thread: Re: marine subroutine
- Next by thread: Re: marine subroutine
- Index(es):
Relevant Pages
|
|