Connecting Tech Pros Worldwide Forums | Help | Site Map

Merge diff processes(.pl files) to one main program(.pl)

Newbie
 
Join Date: Nov 2006
Posts: 15
#1: Nov 12 '06
In my program I have different .pl files.I come to a last stage of merging all files.

my most of the program generate text file and that i need to give input to next process.Output of one file(Text file) to input to another.
for example
1)htmltotext.pl converts html file to text file then
2)tockenized.pl converts text file with all tockens which again i am storing in text file.

there are around 6 more processes i am doing at each point and alli need to do in sequence.

I tried writing main.pl but i don't understand, how do i call all .pl files.i am working on linux.
i tried by creating .pm files and calling all processes as a functions but somehow it don't work.
can any one give a thought on this ?

Member
 
Join Date: Nov 2006
Posts: 83
#2: Nov 12 '06

re: Merge diff processes(.pl files) to one main program(.pl)


Suggested reading:

perldoc perlmod
perldoc perlsub

If that doesn't help you solve the problem, show us some code.
Newbie
 
Join Date: Nov 2006
Posts: 15
#3: Nov 13 '06

re: Merge diff processes(.pl files) to one main program(.pl)


Thanks, I do read but I still need to know which approach is good to use.
I am working on Linux.
I was thinking to use System and pipe commond
to call one program(.pl t.txt) at a time and send it's output to next .pl and next....

second apprach i was thinking was,
call diff modules:
exmp
main.pl

require htmltotext qw(get_html);
require tockenized qw(get_tocken);
require calculate qw(get_cal);
$file=@ARGV[0];
open(OUT,'Query.txt' )|| die "$!";
print OUT htmltotext::get_html($file);
my $tockenized_file=tockenized::get_tocken('Query.txt ');
calculate::get_cal($tockenized_file);

and output of calculate need to be displayed on console.

My problem with this approch is when i am trying to call diff functions from diff modules(.pm files) my program don't gives me output but individually runs perfectly well.
this each of the function is having many small subrutine and have used many modules used in it.
exp
get_html used HTML::Parser ..etc

all works with this main program alone but when i am trying to do next step.it don't give me any output.

is the module having it's own global variables ?

thanks ..

Quote:

Originally Posted by GunnarH

Suggested reading:

perldoc perlmod
perldoc perlsub

If that doesn't help you solve the problem, show us some code.

Member
 
Join Date: Nov 2006
Posts: 83
#4: Nov 14 '06

re: Merge diff processes(.pl files) to one main program(.pl)


Quote:

Originally Posted by kdsutaia

Thanks, I do read but I still need to know which approach is good to use.

I'd say that the preferred approach would be the use of modules in .pm files.

Quote:

Originally Posted by kdsutaia

... output of calculate need to be displayed on console.

My problem with this approch is when i am trying to call diff functions from diff modules(.pm files) my program don't gives me output but individually runs perfectly well.

It's difficult to understand what your problem is. Please post some short and simplified code, that illustrates what it is you are trying to do. Something like this:
Expand|Select|Wrap|Line Numbers
  1. # main.pl
  2. use Mymodule;
  3. my @numbers = (2, 4, 3);
  4. my $product = Mymodule::multiply( @numbers );
  5. print "$product\n";
  6.  
  7. # Mymodule.pm
  8. package Mymodule;
  9. sub multiply {
  10.     my $product = shift;
  11.     $product *= $_[$_] for 0..$#_;
  12.     $product;
  13. }
  14. 1;
  15.  
Reply