maddfisherman has asked for the wisdom of the Perl Monks concerning the following question:

I think these lines should work but both paragraphs give me a compilation error. Any ideas.
$xtemplate = join("", @xtemplate); @template = $xtemplate =~ /^(.*?)\*{4}filename.ext\*{4}/sg; push (@template, $xtemplate =~ /\*{4}filename.ext\*{4}(.*?)\*{4}title\ +*{4}/sg; push (@template, $xtemplate =~ /\*{4}title\*{4}(.*?)\*{4}headings\*{4} +/sg; push (@template, $xtemplate =~ /\*{4}headings\*{4}(.*?)/sg; for ($i=0; $i <= (@filenames-1); $i++) { open(FILE, ">@filenames[$i]") or die; print FILE QQ(@temlate[0] @title[$i] template[1] @heading[$i] temp +late[2] @stuff[$i] @template[3]); close(FILE); }

Replies are listed 'Best First'.
Re: compilation errors
by HyperZonk (Friar) on Aug 22, 2001 at 03:12 UTC
    Just a quick look reveals the following:
    • You didn't close your parens in the last 3 lines of the first section
    • You are referring to a single member of an array with the wrong variable prefix (that is, it should be $filename[$i], don't use the @).
    Other errors may be in there, but until you fix those, you're not going to get anywhere.

    By the way, a list of errors encounters always helps.

    -HZ
Re: compilation errors
by little (Curate) on Aug 22, 2001 at 03:14 UTC
    mising brackets I guess :-)
    push (@template, $xtemplate =~ /\*{4}filename.ext\*{4}(.*?)\*{4}title\ +*{4}/sg; versus push (@template, $xtemplate =~ /\*{4}filename.ext\*{4}(.*?)\*{4}title\ +*{4}/sg);


    Have a nice day
    All decision is left to your taste
    Update
    read brackets as parens, and excuse my english ;-)
Re: compilation errors
by runrig (Abbot) on Aug 22, 2001 at 03:12 UTC
    Many of us are busy people. It would help us to help you if you mentioned what the error is, and which line it is on.
Re: compilation errors
by maddfisherman (Sexton) on Aug 22, 2001 at 03:21 UTC
    Im running perl on-line in the cgi-bin and all it says is that it aborted due to compilation errors, where do i get more specific error messages revised code
    $xtemplate = join("", @xtemplate); @template = $xtemplate =~ /^(.*?)\*{4}filename.ext\*{4}/sg; push (@template, $xtemplate =~ /\*{4}filename.ext\*{4}(.*?)\*{4}title\ +*{4}/sg); push (@template, $xtemplate =~ /\*{4}title\*{4}(.*?)\*{4}headings\*{4} +/sg); push (@template, $xtemplate =~ /\*{4}headings\*{4}(.*?)/sg); for ($i=0; $i <= (@filenames-1); $i++) { open(FILE, ">@filenames[$i]") or die; print FILE QQ($temlate[0] $title[$i] $template[1] $heading[$i] $te +mplate[2] $stuff[$i] $template[3]); close(FILE); }

      See my CGI Help Guide node for answers to this and a lot of other questions with recalcitrant CGI scripts.

      cheers

      tachyon

      s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      use strict;
      use warnings;

      Have a nice day
      All decision is left to your taste