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; #Global variable $n
  print "Hello, sailor number $n!\n";
}


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?

Reply via email to