in reply to A Reg Exp Question

First off, you can pick up the entire file in one bang by setting $/
open(IN,"somefile.pl"); undef $/; $string = <IN>;
save yourself a while and a join.
$string = q{ print "Content-type:text/html\n\n"; print "Some big hunk of code\n"; print("Content-type:text/html","\n","\n"); print ('Content-type: text/html',"\n","\n"); print "Yet another big hunk of code\n"; print "Yet more big hunks of code\n"; print ("Content-type: text/html"); print 'Content-type: text/html',"\n +\n"; print "Some other big hunk of code that does something really cool\n"; print ("Content-type: text/html"); print 'CONTENT-type: text/html' , " +\n", "\n"; print "Some code that ends the program\n"; }; print $string,"\n"; $string =~ s/print[\s'"\(]+content-type:\s*text\/html[\\nr\s'"\),]+;// +gi; print "---------------\n"; print $string,"\n";
This covered all the 'normal' ways of printing a line that I could think of. I you run across any more, I'll update the expression.
/\/\averick

Replies are listed 'Best First'.
RE:(2) A Reg Exp Question
by swiftone (Curate) on Jun 28, 2000 at 19:49 UTC
    Of course, good programming style dictates that $/ should be made local in a block, so you don't trample any exterior variation:
    { open(IN,"somefile.pl"); local $/; undef $/; $string = <IN>; } #previous version of $/ is now restored
      oh yeah, sorry. :)
      I also realized that my expession doesn't handle file handles (props to ZZamboni)
      I'll fix both here shortly.

      /\/\averick