To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.off-topic.geekOpen lugnet.off-topic.geek in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Off-Topic / Geek / 2250
2249  |  2251
Subject: 
Re: Strip surplus white space with Perl
Newsgroups: 
lugnet.off-topic.geek
Date: 
Sun, 29 Oct 2000 22:06:43 GMT
Viewed: 
178 times
  
On Sun, Oct 29, 2000 at 10:00:13PM +0000, Christopher Lindsey wrote:

[snip]

After reading that paragraph a while back I decided that I'd stick with
while loops for most cases -- sometimes while debugging or modifying
my code I don't think about this type of change, so I wouldn't necessarily
have the presence of mind to switch from /g to a while loop.  But if it's
already in a while loop, I don't have to worry about it.

Mind you, I only do this when I might access $& et al.

of course, if you're using $&, you don't care about efficiency anyway, so you might as well put your regexp in a while loop.  But if you do care about speed, you'd go with the /g - otherwise, you're restarting the same regexp over a string over and over again, instead of running it once.

I love perl, btw :)

:)

--
Dan Boger / dan@peeron.com / www.peeron.com / ICQ: 1130750
<set:512_1>:  Building Set (LEGO/DUPLO/LEGO PreSchool), '70



Message is in Reply To:
  Re: Strip surplus white space with Perl
 
(...) There are some days when I shouldn't touch a keyboard. I read and reread his initial posting and could have sworn that it said "It *does* matter to me which one..." I think you just went in and edited the message. ;) I guess it's one of those (...) (24 years ago, 29-Oct-00, to lugnet.off-topic.geek)

10 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR