in reply to Re^3: displaying html file in the browser using perl
in thread displaying html file in the browser using perl

Yes you are right, i meant $1.I had changed my code. Now, I can include the file but think i need to change my regular expression. At the moment the contents of $1 is #include file="includes/sites.html" --> . I just need to get the the filename rather than entire thing and hence it keeps on coming back as no file found. Thanks, I really appreciate all your help.
  • Comment on Re^4: displaying html file in the browser using perl

Replies are listed 'Best First'.
Re^5: displaying html file in the browser using perl
by Corion (Patriarch) on Dec 19, 2016 at 13:47 UTC

    My tip is to never use $1 (and its other numbered siblings) in a subroutine that doesn't also set them up. Always pass them around as parameters and use the parameters in the subroutine only. My example shows that approach.

    This is IMO the better approach because it avoids the problem that a subroutine itself might execute another match (maybe for debugging) and then will overwrite the value you wanted to use.

      ok, i have updated the code so it uses $filename. But iam still having problems getting the name of the file from the regular expression.It still gets the entire include filename="hh.html--> Will keep you updated how i get on. Thanks, for all your help so far.