For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > December 2004 > How to create and use external modules with ActiveState Perl 5.8+?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to create and use external modules with ActiveState Perl 5.8+?
Siegfried Heintze

2004-12-29, 3:56 pm

I'm trying to follow the example Larry Wall's "Programming Perl" book and it
is not working with ActiveState 5.8+.



Here is sample.pm:

package sample;

require Exporter;

our @ISA = ("Exporter");

our @EXPORT qw($convex_pl);

$convex_pl = "/cgi-shl/convex.pl";

1;



Here is test_sample_module.pl in the same directory:

use sample;

print $convex_pl;





I get a syntax error:

syntax error at sample.pm line 4, near "@EXPORT qw($convex_pl)"

Compilation failed in require at test_sample_module.pl line 1.

BEGIN failed--compilation aborted at test_sample_module.pl line 1.


Jonathan Paton

2004-12-29, 3:56 pm

....
>
> our @EXPORT qw($convex_pl);


This is supposed to be a list to array assignment, except that the
assignment operator "=" is missing. Try:

our @EXPORT = qw($convex_pl);

....
> syntax error at sample.pm line 4, near "@EXPORT qw($convex_pl)"


This message tells you there was a syntax error, which means
the code you have is not valid perl. The line number, and what it says
it is near helps pinpoint the problem.

> Compilation failed in require at test_sample_module.pl line 1.


This message tells you your script couldn't compile because the
module failed to load.

> BEGIN failed--compilation aborted at test_sample_module.pl line 1.


This message tells you the BEGIN block failed. That is because
"use" is shorthand for:

BEGIN { require Module; import Module LIST; }


Hopefully, by carefully examining the error message you can avoid
having to ask. Perhaps the example had a misprint.

Jonathan Paton

--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 03+4
00+4 00+8 1-21 01+1 00+5 01-7 >=~/ \S\S \S\S /gx) {m/(
\d+) (.+) /x,, vec$ J,$p +=$2 ,8,= $c+= +$1} warn $J,,
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com