Tutorial for writing modules (newbie ones/ portable ones) 
Author Message
 Tutorial for writing modules (newbie ones/ portable ones)

Hi,
I wonder if there's any good tutorials for creating modules (non
platform specific since I use Macperl and want it to be portable to Unix
and NT as well).
Is a module timesaving or timeconsuming? What I mean is,
does the script get executed faster if I use a module for certain tasks or
does it take longer time to get executed/loaded ?
Yours sincerely
Jimmy Lantz


Sat, 23 Nov 2002 03:00:00 GMT  
 Tutorial for writing modules (newbie ones/ portable ones)


 | Hi,
 | I wonder if there's any good tutorials for creating modules (non
 | platform specific since I use Macperl and want it to be portable to Unix
 | and NT as well).
 | Is a module timesaving or timeconsuming? What I mean is,
 | does the script get executed faster if I use a module for certain tasks
 | or
 | does it take longer time to get executed/loaded ?

depends on the module.

I strongly recommend use of File::Spec (but 0.8 is not compatible with
the current MacPerl, so use version 0.7 (see http://testers.cpan.org/
for details on any module)) so that you can get proper local use of
:current_dir:directory:file or ./current_dir/directory/file, etc etc.

can you give us a better idea of what it is you want to do ? Perhaps
other modules may be appropriate as well.

--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.  



Sat, 23 Nov 2002 03:00:00 GMT  
 Tutorial for writing modules (newbie ones/ portable ones)
I want to put some of my frequently used subs in one module so that I
don't
have to retype them / copy them all the time.
I have some small nifty ones like reading the dir, opening files,
proccesing some scalars through some regexp.
I know that there probably 1 million different modules already doing the
thsings I want,
but I just wanna use my own code.

My question about time consumming / timesaving modules:

I have things like the following sub

sub read_folder
{


closedir(DIR);

Quote:
}

Would it take longer time for the Script to process or would it take
shorter time if I
would call it like :

use ReadFolder;

$dir = 'HD:some:folder:';
ReadFolder::read_folder("$dir");


// Jimmy Lantz

Quote:



>  | Hi,
>  | I wonder if there's any good tutorials for creating modules (non
>  | platform specific since I use Macperl and want it to be portable to Unix
>  | and NT as well).
>  | Is a module timesaving or timeconsuming? What I mean is,
>  | does the script get executed faster if I use a module for certain tasks
>  | or
>  | does it take longer time to get executed/loaded ?

> depends on the module.

> I strongly recommend use of File::Spec (but 0.8 is not compatible with
> the current MacPerl, so use version 0.7 (see http://testers.cpan.org/
> for details on any module)) so that you can get proper local use of
> :current_dir:directory:file or ./current_dir/directory/file, etc etc.

> can you give us a better idea of what it is you want to do ? Perhaps
> other modules may be appropriate as well.

> --
> send mail to mactech (at) webdragon (dot) net instead of the above address.
> this is to prevent spamming. e-mail reply-to's have been altered
> to prevent scan software from extracting my address for the purpose
> of spamming me, which I hate with a passion bordering on obsession.



Sat, 23 Nov 2002 03:00:00 GMT  
 Tutorial for writing modules (newbie ones/ portable ones)
[posted and mailed]

Quote:
> // Jimmy Lantz




> >  | Hi,
> >  | I wonder if there's any good tutorials for creating modules (non
> >  | platform specific since I use Macperl and want it to be portable to Unix
<SNIP>

> > depends on the module.

> > I strongly recommend use of File::Spec (but 0.8 is not compatible with
<SNIP>
> > can you give us a better idea of what it is you want to do ? Perhaps
> > other modules may be appropriate as well.

<SNIP>
<<<Jeopardy-ectomy attempted: it is good netiquette to put replies
AFTER the pertinent section in the posting>>>

Quote:

> I want to put some of my frequently used subs in one module so that I
> don't
> have to retype them / copy them all the time

Try looking at the mounds of documentation that comes with each and
every Perl distribution. In it you'll find:

perlmod

(not sure how to access them for the Mac)

This goes into some detail concerning how to write/use modules. It
also points to other pertinent documentation as well.

Enjoy.

joe



Sun, 24 Nov 2002 03:00:00 GMT  
 Tutorial for writing modules (newbie ones/ portable ones)

 | Try looking at the mounds of documentation that comes with each and
 | every Perl distribution. In it you'll find:
 |
 | perlmod
 |
 | (not sure how to access them for the Mac)
 |
 | This goes into some detail concerning how to write/use modules. It
 | also points to other pertinent documentation as well.

seems to be pretty straightforward for the Mac as long as you don't
attempt anything Mac-specific function-wise, and stick to your guns in
making any module work as cross-platorm compatible as you can.

I've been pleasantly surprised more than once at how well this all
works, even considering that there hasn't been an update to MacPerl in a
while.

I've made a few half-assed attempts at finding out the status and prep
of an update to 5.005 or later, but haven't found anything of importance
yet, and haven't pursued it seriously as I don't have as much time as
I'd like.

Still, on the whole, MacPerl works 'as advertised' <grin> so as long as
you follow good module-making procedures you shouldn't have much trouble
writing one that works. :)

--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.  



Tue, 26 Nov 2002 03:00:00 GMT  
 Tutorial for writing modules (newbie ones/ portable ones)

 | My question about time consumming / timesaving modules:
 |
 | I have things like the following sub
 |
 | sub read_folder
 | {

 | opendir(DIR, "$directory") or die "cannot open $directory";

 | closedir(DIR);
 | }
 |
 | Would it take longer time for the Script to process or would it take
 | shorter time if I
 | would call it like :
 |
 | use ReadFolder;
 |
 | $dir = 'HD:some:folder:';
 | ReadFolder::read_folder("$dir");
 |

well there's one sure way to test this :
    use Benchmark;

:)

--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.  



Tue, 26 Nov 2002 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Newbie ? - Delete one and only one line

2. two modules -- one in /usr/lib/perl5 one not

3. One question on writing Perl module

4. Any one knows good off-line perl tutorial

5. Two questions, one easy, one hard.

6. Two questions, one easy, one hard

7. search for one line and print that line and the one after it

8. removing one array from the other one

9. Assigning one symbol table to another one

10. gave a2p, s2p a one-liner, want one-liner back

11. test for one of a number of values (more than one way to do it)

12. Generate more than one page with one script

 

 
Powered by phpBB® Forum Software