Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.pm structure? 1

Status
Not open for further replies.

edelwater

Programmer
Jun 29, 2000
203
EU
I have a question on module structure and usage::

I have 2 different .pl files they both use .PM's I have put in a subdir. Inside the .pl I have put the complete list of "use" statements for all PM's available.

Now I noticed that in both .pl's the same if-then loop exists. This is not a sub.

So... is there a way to just include exactly the same code on that particular spot in the .pl file OR should i write a new sub, define input parameters and output parameters (which were previously the variables in scope of the .pl) and how do then deal with the included .PM's ? Should I include all PM's again in this new PM?




--
 
To make ypur code more flexible you can define a new sub in your .pm file and call that in your .pl files. Should that new sub accepts and returns values is dependent on your code/requirement.
In doing so you don't have to include all modules in your new .pm file. You only have to include new .pm into your perl scripts. But why don't you define this new subroutine into some existing module?



--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Thank you for your answers but I'm still not there I think, I wonder if you could give me some more hints.

I will make it practical to explain what I'm trying to do:

I have written "batch file SIF.pl" to provide an automatic integration between Siebel Projects and Rational ClearCase. Now we have a new type of data where we wrote "batch file ADM.pl" for.

Both files have access to the folder /CLEARCASE in which several modules (.pm) are available that are in a sense general e.g. the module called "view.pm" contains procudures to query Views. They can be included in any project.

The 2 batch files have the following logic: a) receive input via the command line (very different parameters) b) a set of processing logic (different) but in step c) it is determined if they either should be checked in (existing version) or should be added to source control (new version).

This last bit is in a sense not something general to "ClearCase" but a typical if/then clause in the main loop.

However since they are in 2 different spots I would like to put them in 1 include file so, whenever there is a change request I only have to edit 1 file.

In both files I include all existing needed ClearCase PM's:

Code:
use lib	"\\\\bla\\projects\\blabla\\CC\\" . "ClearCase";
use Globals;
use Dialogs;
use ClearTools;
use Component;
use Vob;
use Compare;
use DateUtils;
use NewVersion;
use AddToSourceControl;
use Stream;
use View;
use Activity;
use Logger;

Now... If I would generalize the if-then loop I could create a SUB out of the if-then loop that receives as input parameters all things it now has as "available variables inside the scope of the .pl file". Then I would place this new sub in a new .pm. But inside this new .PM I would need to include again all .pm's as listed before, which seems a bit useless (since most of them are called from the loop or therein).

So therefore I wonder if there is nothing like a real include which could be called from the exact line in which it is placed, executes the code, and then just goes on in the main loop, would I use "require/use" for this? Or is this against best practices?






































--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top