can you post the exact format of your include line
 and what is the logic to map the base to actual values.

 in
 base/includefile.ext

 how do we get to know the value of base


 here is a general solution assumin that tha format of your include line is
 include "base/filename.extenction"

 all the nasses should be stored in a hash
 called %baseHash stored in a hash


 my $outStr = makeOutput("Source_File_Name");

 open(OUT, ">Output_File_Name");
     print OUT $outStr;
 close(OUT);

 sub makeOutput($){
         my ($source) = @_;
         my $fText = file2Str($source);

         $fText =~
 s/include\s"(w+)\/(w+\.w+)"/$baseHash{$1}\/makeOutput($2)/emg;

         return $fText;

 }

 sub file2Str($){

     my ($fn) = @_;
     open(FH, "<$fn");
     my @fLines = <FH>;
     close(FH);

     return join('', @fLines);
 }









 ________________________________________
 Rakhitha Karunarathne
 Web Master
 www.Ad-Man.tk - Free Unlimited Banner Rotators
 ________________________________________



> ----- Original Message ----- 
> From: "Girish N" <[EMAIL PROTECTED]>
> To: "'LRMK'" <[EMAIL PROTECTED]>
> Sent: Wednesday, May 26, 2004 6:10 PM
> Subject: RE: need help(urgent)
>
>
> > Hey
> > Thanks a lot for the help
> > But I have one more problem....sorry to bother u but this is kind of
> > urgent...
> > Include statement in my code looks like this
> >
> > include $(BASE_DIR)/make_include
> >
> > I need to get the value of the $(BASE_DIR) and then open the file
> > base/make_include
> > Can u plz tell me how to do that......i am bad at pattern
matching....and
> I
> > need to finish this today....
> >
> > Plz reply back
> > Thanks & Regards
> > Girish
> >
> >
> >
> > -----Original Message-----
> > From: LRMK [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, May 26, 2004 5:11 PM
> > To: Girish N
> > Cc: [EMAIL PROTECTED]
> > Subject: Re: need help(urgent)
> >
> > try this, this should work
> >
>
____________________________________________________________________________
> > __________________________________
> >
> >
> > #Pass the file name as a parameter
> > sub printFile($){
> >     my ($fname) = @_;
> >
> >     #Load the spesified file
> >     my @lines = readFile($fname);
> >     chomp @lines;
> >
> >
> >     foreach my $line (@lines){
> >
> >         if ($line =~ m/include\s"(\w+\.\w+)"/i){  # check for the
include
> > line
> >             printFile($1);
> >         }else{
> >             print "$line\n";
> >         }
> >     }
> >
> >
> >
> >
> > }
> >
> > sub readFile($){
> >     my ($fname) = @_;
> >     open(FH, "<$fname") or die $!;
> >
> >     my @fLines= <FH>;
> >     close(FH);
> >
> >     return @fLines;
> >
> > }
> >
> >
> >
> >
> >
> >
> >
> > ________________________________________
> > Rakhitha Karunarathne
> > Web Master
> > www.Ad-Man.tk - Free Unlimited Banner Rotators
> > ________________________________________
> >
> >
> >
> > ----- Original Message ----- 
> > From: "Girish N" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Wednesday, May 26, 2004 4:49 PM
> > Subject: need help(urgent)
> >
> >
> > > Hi All
> > >
> > > I am stuck with this script which I need to finish today...
> > >
> > >
> > >
> > > What I am supposed to do is
> > >
> > > 1)       parse a file and search for included files and insert those
> > > included files in the file.
> > >
> > > Eg.
> > >
> > > File1
> > >
> > > Lkdfs
> > >
> > > Sdfdsfds
> > >
> > > Sdfsdf
> > >
> > > Include "one.txt"
> > >
> > > Sdfdsf
> > >
> > > Sdfsdf
> > >
> > > Werewr
> > >
> > > Tytry
> > >
> > >
> > >
> > > Where one.txt is
> > >
> > > A
> > >
> > > B
> > >
> > > C
> > >
> > > D
> > >
> > > E
> > >
> > > F
> > >
> > >
> > >
> > > The expected result is
> > >
> > >
> > >
> > > File2
> > >
> > > Lkdfs
> > >
> > > Sdfdsfds
> > >
> > > Sdfsdf
> > >
> > > A
> > >
> > > B
> > >
> > > C
> > >
> > > D
> > >
> > > E
> > >
> > > F
> > >
> > > Sdfdsf
> > >
> > > Sdfsdf
> > >
> > > Werewr
> > >
> > > Tytry
> > >
> > >
> > >
> > >
> > >
> > > Please help me with this ....
> > >
> > > Thanks in advance
> > >
> > > Girish
> > >
> > >
> >
> >
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to