a very simplistic example of a perl module

B

BH

Hi,

I would like to move some subroutines into a module, perlmod and other
tutorials online seem to provide too much detail. Can someone
demonstrate with a simple Module.pm which only have one subroutine and
how this module can be used please?

Regards,

BH
 
X

xhoster

BH said:
Hi,

I would like to move some subroutines into a module, perlmod and other
tutorials online seem to provide too much detail. Can someone
demonstrate with a simple Module.pm which only have one subroutine and
how this module can be used please?

Regards,

BH

Sure. But without without knowing some of the details (like package
namespaces, at least) you miss most of the benefit to be had from using
modules in the first place.


$ cat Foo.pm
sub foobar {
return "This is the return value";
};
1;
__END__

$ cat foo.pl
use strict;
use warnings;
use Foo;
print foobar();
__END__

$ perl -l foo.pl
This is the return value

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
 
B

BH

Thanks.

Can you add to the simple example another subroutine not to be
exported, as well as 2 variables, one to exported and one not to be?

Regards,

BH
 
X

xhoster

BH said:
Thanks.

Can you add to the simple example another subroutine not to be
exported,

No. Exporting is one of those details you didn't want to bother with.
If you now want to bother with it, then go back to reading the docs
you gave up on. I'm going to read them to you.
as well as 2 variables, one to exported and one not to be?

Who will receive credit for your homework, me or you?


Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
 
B

BH

Interesting! It's interesting someone actually thinks that any typical
school/university will teach Perl as a subject? ;)
 
T

Tad J McClellan

[ If you don't want to continue to look silly, then do not top-post.
Text rearranged into actual chronological order.
]

BH said:
On Feb 26, 7:51 pm, (e-mail address removed) wrote:

Interesting! It's interesting someone actually thinks that any typical
school/university will teach Perl as a subject? ;)


I don't "think" it is taught, I "know" it is.

I have taught a for-credit Perl class at a typical university.
 
U

Uri Guttman

TJM> [ If you don't want to continue to look silly, then do not top-post.
TJM> Text rearranged into actual chronological order.
TJM> ]



TJM> I don't "think" it is taught, I "know" it is.

TJM> I have taught a for-credit Perl class at a typical university.

and there are certificate programs in perl at many colleges
too. extensions schools (even harvard) teach perl. it isn't used much as
the primary language for all compsci classes but it is taught in places.

uri
 
C

ccc31807

Interesting! It's interesting someone actually thinks that any typical
school/university will teach Perl as a subject? ;)

I've had five years of post-bat CS and SE, and have never been exposed
to Perl in a University environment, but I ~have~ been exposed to
COBOL, Scheme, Python, C, Java (lots), Microsoft languages (lots),
shell scripts, assembly, X languages (XPath, XSLT, etc.), Mate,
Erlang, and others I can't remember. No Perl, none at all.

OTOH, I've taught at a college and taught the Perl course, which was
taught as part of a state required curriculum. Yes, my state mandated
that students learn Perl, but the curriculum was 20 years old when I
taught, and that was five years ago, and it still IS the curriculum.

I find it ironic that self-respecting academics won't touch Perl with
a ten foot pole, yet teach it because of 20 year old state mandates.
Don't get me wrong ... Perl is perhaps the most useful technology
invented, but maybe that's why academics don't like it.

CC
 
J

John W. Kennedy

ccc31807 said:
Perl is perhaps the most useful technology
invented, but maybe that's why academics don't like it.

No, Perl simply doesn't offer anything particularly new or unique or
historically significant in the field of programming languages, and in
some ways, it's just plain grotty. Learning Perl may be vocational
training, but it's not education. (You don't get a degree in automotive
engineering because you know how to replace the carburetor on a '57
Chevy; you get it by learning metallurgy, and flame-front physics, and
airflow mechanics.)

--
John W. Kennedy
"The whole modern world has divided itself into Conservatives and
Progressives. The business of Progressives is to go on making mistakes.
The business of the Conservatives is to prevent the mistakes from being
corrected."
-- G. K. Chesterton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top