On Wed, Apr 9, 2008 at 7:14 PM, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: > Chas. Owens wrote: snip > > There are at least three downsides to using the substr function: > > 1. multiple function calls > > 2. lots of typing > > 3. no guarantee that the input string is in the right format > > > > That comment surprised me. While I can agree that a regex makes it easier > to validate input, the difference in typing is insignificant, and the regex > is often more expensive to run than multiple calls for substr(). Please see > the benchmark below. snip
The amount of typing is insignificant if the variable name is short and you don't have a lot of captures. Even the fairly verbose regex (due to the broken nature of \d on newer versions of Perl) with the very short variable used four fewer characters and it does more work. -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/