On Wed, 2004-05-26 at 11:49, Girish N wrote:
> 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
> 

Try this:


#!/usr/bin/perl -i -pw
use strict;

s/^Include\s*(.*)/
  open(FILE,$1) || die "could not open file $1 ($!)\n";
  while (<FILE>) {
    print;
  }
  close(FILE);
  '';
 /e;


 
> 
> 
> 
> Please help me with this ....
> 
> Thanks in advance
> 
> Girish
-- 
Josà Alves de Castro <[EMAIL PROTECTED]>
Telbit - Tecnologias de InformaÃÃo


-- 
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