in reply to Weird printing

im sorry fellas the code should be like this..
@cat1 = `/bin/cat template.html`; #template html $cat2 = `/bin/cat data.txt`; #data file contains html snipets open(F, ">foo.html"); foreach (@cat1) { s/%%insert_here%%/$cat2/ge; } print F @cat1;

Replies are listed 'Best First'.
RE: Re: Weird printing
by LunaticLeo (Scribe) on Aug 09, 2000 at 19:53 UTC
    I have to take issue with your
    $cat2 = `/bin/cat data.txt`;
    Try undefing the record separator then read in the file from a normal filehandle.
    open(FH, 'data.txt') or die(); my $tmp_fs = $/; my $cat2 = <FH>; $/ = $tmp_fs; close(FH);
      local will do this for you automatically, if you scope it correctly:
      my $cat2; { open(FH, 'data.txt') || die "Some error: $!"; local $/; $cat2 = <FH>; close FH; }
      You have to make sure $cat2 is defined outside of the block, though, otherwise it'll go out of scope when you want to use it.