On Thursday 20 December 2007 10:36, Andy Dixon wrote:
>
> Hello,

Hello,

> I have written a small module with a function that returns some text.
>
> However, when I run it, from a test script, I get:
>
> Undefined subroutine &external::RETURN called at external.pm line 41.
>
> The subroutine is thus:

Do you have warnings and strict enabled?

use warnings;
use strict;


> sub test($) {

Don't use prototypes:

http://library.n0i.net/programming/perl/articles/fm_prototypes/


> my $data = @_;

An array in scalar context will return the number of elements of that 
array so you need to either use list context:

my ( $data ) = @_;

Or assign a scalar in scalar context:

my $data = $_[ 0 ];

Or:

my $data = shift;


> $data =~ s/cheese/ham/g;

$data will not be modified as it only contains numbers.

You may want to anchor your pattern.  Do you want to change the word 
'cheesecloth' to 'hamcloth'?


> RETURN ($data);

Perl is case sensitive:

    return $data;


> }


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to