RE: magic import of extensions?

2001-08-07 Thread Tu, Hanming

Yes. Here is how

1) In your MyPackage.pm, you import the Exporter module as

require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(init doThis doThat);

2) install MyPackage in a search directory, i.e., including your path in
@INC

3) Then in your scr.pl or other programmer's scripts

use MyPackage;

Those subs will be imported into the scripts.

Hanming


-Original Message-
From: Edwin Günthner [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 07, 2001 10:30 AM
To: [EMAIL PROTECTED]
Subject: magic import of extensions?


Hi there,

I am wondering if it is possible to create my own module
and to allow programers to use it without any importing or so.

For example, if MyPackage has subs like "init", "doThis", 
"doThat" - is it possible to have a script that looks like:

scr.pl:

init;
doThis $someArg;
doThat $anotherArg $oneMore;

and just run it with 

> perl scr.pl

.. so what I am looking for is a mechanism
to automatically load MyPackage whenever
Perl starts. Is that possible?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Regular Expressions

2001-08-06 Thread Tu, Hanming

You should use qr instead of qq. -- Hanming 

-Original Message-
From: Adimoolam Narayanan [mailto:[EMAIL PROTECTED]]
Sent: Monday, August 06, 2001 3:18 PM
To: [EMAIL PROTECTED]
Subject: Regular Expressions


Hi,

In a nutshell, I have been trying to store a reg. exp. in a variable so that

it can be called later. If it can be stored in a variable, is there any 
penalty incurred in terms of run time efficiency, etc?

Explanation of the above question is given below:
I am storing the reg. exp. in "$variable" and use its contents for pattern 
matching in two different ways.

1) $variable = 
qq(^\s*Content\s+\w+,\s+\d{1,2}\s+\w+\s+\d{4}\s+\d+:\d+:\d+\s+-\d{4});

if (/$variable/) {

processing

}


or something like this:

2) $variable = 
qq(m/^\s*Content\s+\w+,\s+\d{1,2}\s+\w+\s+\d{4}\s+\d+:\d+:\d+\s+-\d{4}/);

if ($_ =~ $variable) {

processing

}

Is it possible to something like that or is there any other way of doing it?

Your feedback will be greatly appreciated.

Looking forward to hearing from you,

naren


_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




How to construct test scripts?

2001-08-06 Thread Tu, Hanming

Hi,

I wrote a few Perl modules, but I have never written a structured testing
script. I am studying ExtUtils::MakeMaker and Test modules, but have
difficult to understand them. It will be greatly appreciated if some of you
can give me some examples or point me to some references!

Thanks.

Hanming Tu
[EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]