Path: utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Multi-line strings and $* Message-ID: <10259@jpl-devvax.JPL.NASA.GOV> Date: 6 Nov 90 18:23:43 GMT References: <1391@tharr.UUCP> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 25 In article <1391@tharr.UUCP> gustav@tharr.UUCP (Paul Moore) writes: : I'm having a bit of trouble understanding how to use $* to handle : multiline strings. : : I have a string, $article, which contains a large number of lines of : text (OK, so it's a news article...) The article may end with any number : of blank lines (ie, \n\n\n), which I want to remove. : : My first thought is $article =~ s/\n+$//, with $* = 0. But the manual says : "Pattern matches on strings containing multiple newlines can produce : confusing results when $* is 0". Um. : : However, if $* = 1, there seems to be no way of anchoring a pattern to : the end (or the beginning) of a string. : : At this point, I started getting frustrated... Actually, $* only applies to ^ and $, not \n. So just leave it 0, and treat \n like a normal character, and it should work fine. If it DOESN'T work fine, it's a bug. The manual should definitely be clearer... Larry