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