RE: marine subroutine



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

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.




.



Relevant Pages

  • Re: "Counter" in macro
    ... > Dim Myrange As Range ... > MsgBox Count ... > End Sub ... Sub marine() ' ...
    (microsoft.public.excel.programming)
  • Wrapping FileSystemWatcher to prevent crossthread ops
    ... Public Shadows Event Changed(ByVal sender As Object, ... Private Delegate Sub DelegatorFSE(ByVal sender As Object, ... Private Sub watch_Changed(ByVal sender As Object, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Global.asax not firing
    ... Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) ... ' Fires when the application is started ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Global.asax not firing
    ... Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) ... ' Fires when the application is started ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: possible to create one control array with different controls?
    ... That's a sub of the base FORM class which is why I surmise you put ... Private Overloads Sub OnEnter(ByVal sender As System.Object, ... If TypeOf sender Is TextBox Then ... I have 3 textboxes and 1 combobox on a form. ...
    (microsoft.public.dotnet.languages.vb)