Re: marine subroutine

2007-08-31 Thread Dr.Ruud
Chas Owens schreef: Martin Barth: Andrew Curry: That's rubbish, but you get a warning like: main::a() called too early to check prototype at -e line 1. Use Prototypes at the beginning of your file if you want to write the subs at the end. snip This would be a good point but for the

Re: marine subroutine

2007-08-31 Thread Chas Owens
On 8/31/07, Dr.Ruud [EMAIL PROTECTED] wrote: snip This is nice content, but not presented well, so I wonder how many people take the time to read and grok it. Maybe you can transform it into an article, maybe both on this list and on PerlMonks? (and please give away the answers :) snip An

Re: marine subroutine

2007-08-31 Thread Dr.Ruud
Chas Owens schreef: An article would be redundant, we already have Tom Christiansen's masterful article Far More Than Everything You've Ever Wanted to Know about Prototypes in Perl*. [...] * http://library.n0i.net/programming/perl/articles/fm_prototypes/ OK, thanks. I presume it is quite

marine subroutine

2007-08-30 Thread Amichai Teumim
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

marine subroutine

2007-08-30 Thread Amichai Teumim
Oh that curly! Ignore my previous message. Thank you.

Re: marine subroutine

2007-08-30 Thread Jeff Pang
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

Re: marine subroutine

2007-08-30 Thread Martin Barth
Hi, be nice to yourself and allways use strict; and don't call subs with , unless you know why you need . hopefully you can avoid some problems when you're writing perl code. #!/usr/bin/perl use strict; marine(); HTH, Martin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For

marine subroutine

2007-08-30 Thread Amichai Teumim
i am trying to figure out how to use the subroutine in a library now. so I did this. I name one script sub.pl and the library sub-lib-pl: the script.pl contains: #!/usr/bin/perl use strict; require 'sub-lib.pl'; marine(); The sub-lib.pl contains: #!/usr/bin/perl sub marine { $n += 1;

Re: marine subroutine

2007-08-30 Thread Jeff Pang
2007/8/30, Amichai Teumim [EMAIL PROTECTED]: I get the error: sub-lib.pl did not return a true value at ./sub.pl line 5. Why is that? The value is 1 isn't it? to add 1 at the end of sub-lib.pl,it would work. echo 1 sub-lib.pl when 'require'ing a file,perl need it to return a true value.

Re: marine subroutine

2007-08-30 Thread Amichai Teumim
Yeah that works now. Great. Finally I'm getting this...after months. Thank you. On 8/30/07, Jeff Pang [EMAIL PROTECTED] wrote: 2007/8/30, Amichai Teumim [EMAIL PROTECTED]: I get the error: sub-lib.pl did not return a true value at ./sub.pl line 5. Why is that? The value is 1 isn't

Re: marine subroutine

2007-08-30 Thread anders
On 30 Aug, 09:39, [EMAIL PROTECTED] (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?

RE: marine subroutine

2007-08-30 Thread Andrew Curry
. -Original Message- From: anders [mailto:[EMAIL PROTECTED] Sent: 30 August 2007 09:18 To: beginners@perl.org Subject: Re: marine subroutine On 30 Aug, 09:39, [EMAIL PROTECTED] (Amichai Teumim) wrote: Hi I'm trying to understand subroutines. #!/usr/bin/perl marine() sub marine { $n

Re: marine subroutine

2007-08-30 Thread Beginner
On 30 Aug 2007 at 1:18, anders wrote: On 30 Aug, 09:39, [EMAIL PROTECTED] (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.

Re: marine subroutine

2007-08-30 Thread Martin Barth
On Thu, 30 Aug 2007 15:39:14 +0100 Andrew Curry [EMAIL PROTECTED] wrote: That's rubbish, but you get a warning like: main::a() called too early to check prototype at -e line 1. Use Prototypes at the beginning of your file if you want to write the subs at the end. HTH, Martin -- To

Re: marine subroutine

2007-08-30 Thread Beginner
On 30 Aug 2007 at 17:29, Martin Barth wrote: On Thu, 30 Aug 2007 15:39:14 +0100 Andrew Curry [EMAIL PROTECTED] wrote: That's rubbish, but you get a warning like: main::a() called too early to check prototype at -e line 1. Use Prototypes at the beginning of your file if you want to

Re: marine subroutine

2007-08-30 Thread Digger
-Original Message- From: [EMAIL PROTECTED] Sent: Thu, 30 Aug 2007 16:34:08 +0100 To: beginners@perl.org Subject: Re: marine subroutine On 30 Aug 2007 at 17:29, Martin Barth wrote: On Thu, 30 Aug 2007 15:39:14 +0100 Andrew Curry [EMAIL PROTECTED] wrote: That's rubbish

Re: marine subroutine

2007-08-30 Thread Martin Barth
Hi, I don't get that either !!! #!/bin/perl ### junk.pl ### use strict; use warnings; sayhello(); sub sayhello { print hello\n; } thats because you're not using perls prototyping feature at all. if you define your sub that way: sub sayhallo() { print hello\n; }

Re: marine subroutine

2007-08-30 Thread Chas Owens
On 8/30/07, Martin Barth [EMAIL PROTECTED] wrote: On Thu, 30 Aug 2007 15:39:14 +0100 Andrew Curry [EMAIL PROTECTED] wrote: That's rubbish, but you get a warning like: main::a() called too early to check prototype at -e line 1. Use Prototypes at the beginning of your file if you want to