Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > a very simplistic example of a perl module

Reply
Thread Tools

a very simplistic example of a perl module

 
 
BH
Guest
Posts: n/a
 
      02-26-2008
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
 
Reply With Quote
 
 
 
 
xhoster@gmail.com
Guest
Posts: n/a
 
      02-26-2008
BH <(E-Mail Removed)> wrote:
> 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.
 
Reply With Quote
 
 
 
 
BH
Guest
Posts: n/a
 
      02-26-2008
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

On Feb 26, 7:18*pm, (E-Mail Removed) wrote:
> BH <(E-Mail Removed)> wrote:
> > 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.


 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      02-26-2008
BH <(E-Mail Removed)> wrote:
> 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.
 
Reply With Quote
 
BH
Guest
Posts: n/a
 
      02-27-2008
Interesting! It's interesting someone actually thinks that any typical
school/university will teach Perl as a subject?

On Feb 26, 7:51 pm, (E-Mail Removed) wrote:
> BH <(E-Mail Removed)> wrote:
> > 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.


 
Reply With Quote
 
Tad J McClellan
Guest
Posts: n/a
 
      02-28-2008
[ If you don't want to continue to look silly, then do not top-post.
Text rearranged into actual chronological order.
]

BH <(E-Mail Removed)> wrote:
> On Feb 26, 7:51 pm, (E-Mail Removed) wrote:



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

> 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.


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
 
Reply With Quote
 
Uri Guttman
Guest
Posts: n/a
 
      02-28-2008
>>>>> "TJM" == Tad J McClellan <(E-Mail Removed)> writes:

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> BH <(E-Mail Removed)> wrote:
>> On Feb 26, 7:51 pm, (E-Mail Removed) wrote:



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

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



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

--
Uri Guttman ------ http://www.velocityreviews.com/forums/(E-Mail Removed) -------- http://www.sysarch.com --
----- Perl Architecture, Development, Training, Support, Code Review ------
----------- Search or Offer Perl Jobs ----- http://jobs.perl.org ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
 
Reply With Quote
 
ccc31807
Guest
Posts: n/a
 
      02-28-2008
On Feb 27, 3:54 pm, BH <(E-Mail Removed)> wrote:
> 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
 
Reply With Quote
 
John W. Kennedy
Guest
Posts: n/a
 
      02-29-2008
ccc31807 wrote:
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simplistic URL Rewriting Smithers ASP .Net 3 11-30-2007 09:40 AM
Frames: Simplistic Summary For The Noob? (Pete Cresswell) HTML 20 10-29-2004 04:28 PM
Simplistic DOF question.... Roland Karlsson Digital Photography 2 08-23-2004 07:23 PM
Quick Book file access very very very slow Thomas Reed Computer Support 7 04-09-2004 08:09 PM
Design opinions/urls/snippets requested; parsing simplistic config files John Doe C Programming 3 07-09-2003 03:34 AM



Advertisments