in reply to Re: File opening problems
in thread File opening problems

You mean replace:
open (OUTFILE, ">@htmlLines") or die("Can't rewrite the HTML file.\n") +;
with this? The actual file name?
open (OUTFILE, ">E:/Documents and Settings/Richard Lamb/My Documents/H +TML/test1InDocCSS.html") or die ("Can't open E:/Documents and Setting +s/Richard Lamb/My Documents/HTML/test1InDocCSS.html\n");
So I should be passing the file path as an argument, not the array variable I'm using to store the HTML? Many thanks, Richard

Replies are listed 'Best First'.
Re: File opening problems
by Abigail-II (Bishop) on Aug 19, 2003 at 13:09 UTC
    open needs a filename, not the content of the file to be. If you wouldn't give the file, how is Perl supposed to know which file to open?
    my $file = "whatever"; open my $out, ">", $file or die "Failed to open $file: $!"; print $out @htmlLines; close $out or die "Failed to close $file: $!";

    Abigail

      Just replaced the duff code with this:
      # Replacing original file with reformatted file! my @htmlFile = "@htmlLines"; open (OUTFILE, ">E:/Documents and Settings/Richard Lamb/My Documents/H +TML/test1InDocCSS.html") or die("Can't rewrite the HTML file.\n"); print (OUTFILE @htmlFile); close (INFILE); close (OUTFILE);
      It works! Fantastic!I opened the original html file on my hard-drive a +nd, hey-presto, no images or hyperlinks... Thanks a million Abigail, Richard
        my @htmlFile = "@htmlLines";

        Why? Does this have a point except using more memory than necessary?

        Abigail