[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-AnyPerl] substituting on multiple lines



On Thu, Jul 06, 2000 at 08:50:04PM +0200, allan juul wrote:
> thanks ronald
> for the quick reply. some of your code is new to me and i cant get it working
> i guess my complete document should look like below: (this will just print the
> entire file as it is already)
> thanks
> allan
> ______________________
> 
> #!/pack/collect/bin/perl
> 
> 
> open(MAINLATE, "somefile.html");

Don't forget to make sure the open succeeded:

open(MAINLATE, "somefile.html") or die "Can't open somefile.html: $!\n";


>  {
>  local $/;
>  $text = <MAINLATE>;
>  }
> 
>  $text =~ s!<style>.*</style>!!i;

Oh dear, I forgot about the newlines in the string.

$text =~ s!<style>.*</style>!!is;

The /s modifier allows . to match newlines, so this substitution will match
over multiple lines.  My first suggestion would only match on a single
line.  Sorry about that!


Ronald

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org