> Hi Still trying to get to grips with a simple script, with no luck the
> folders are created OK but only the first 2 items of @pages get made
> the web page returns with a blank page to make matters worse doing a
> 'top' reveals that the process is still running and eating up CPU
> time!

> if ($Exname ne ""){
> $Exname =~ s/ /""/gs;
> $ExFoldername = $Exname."_Folder";  
>       if (!-e "/web/html/ExhibitionFolder/98/$ExFoldername") 
>       { 
>       `mkdir /web/html/ExhibitionFolder/98/$ExFoldername`;
>       `mkdir /web/html/ExhibitionFolder/98/$ExFoldername/$Exname` ;
>       `cp -rp $path/ExhibitionFolder/98/Templates/images
> /web/html/ExhibitionFolder/98/$ExFoldername/$Exname/`;

Comment -- for clarity, you might want to use a temp variable, e.g.:

    my $folder = "/web/html/ExhibitionFolder/98/$ExFoldername";
    if (! -e $folder) {
        `mkdir $folder`; # or die, etc...
        `mkdir $folder/$Exname`;
    }

> #-----------------------------------------------------------------------
> # if directories created OK then open html pages to alter
> #-----------------------------------------------------------------------
>       foreach $NEWPAGE (@pages){
>
>               chomp $NEWPAGE;
>               open(PAGE, "<$path/ExhibitionFolder/98/Templates/$NEWPAGE")
>                        or die("Cannot open template at 80- $!");
>               $npage  = join '', <PAGE>;
>               close PAGE; 
>               
>               while ($NEWPAGE eq "header.html")
>               {
>                       $npage =~ s/#Exname#/$pexname/gs;
>                       $npage =~ s/#dates#/$dates/gs;
>                       $npage =~ s/#Venueadd#/$Venueadd/gs;
>               }
>               while ($NEWPAGE eq "contents.html")
>               {
>                       $npage =~ s/#Exname#/$pexname/gs;
>                       $npage =~ s/#dates#/$dates/gs;
>                       $npage =~ s/#Venueadd#/$Venueadd/gs;
>               }

My guess is you are trying to replace strings in HTML templates, but these
loops will spin forever, because the variable you are modifying ($npage) has
nothing to do with the loop variable ($NEWPAGE).  (It looks like you were
working on two solutions here: one which read the entire template into a
string, and one which worked on a line at a time.  You kept the file read
from the first solution and the loop from the second.)

I am uncertain what the conditions ($NEWPAGE eq "foo.html") are about, but
you
probably want something like this.  (Warning: not debugged.)

    foreach $NEWPAGE (@pages)
    {
        chomp $NEWPAGE;
        open(PAGEIN, "<$path/ExhibitionFolder/98/Templates/$NEWPAGE")
            or die("Cannot open template: $!\n");
        open(PAGEOUT, ">$folder/$Exname/$NEWPAGE")
            or die("Cannot open page output: $!\n");

        while (<PAGEIN>) {
            s/#Exname#/$pexname/g;
            s/#dates#/$dates/g;
            s/#Venueadd#/$Venueadd/g;
            print PAGEOUT;
        }

        close PAGEIN;
        close PAGEOUT;
    }

Regards,
Jonathan


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to