On Wednesday, April 24, 2002, at 02:45 , Kevin Cornmell wrote: [..]
> Or try anchoring that regex. > > if ($radentry =~/\n\n$/){ > foo; > } this rules. > -----Original Message----- > From: John W. Krahn [mailto:[EMAIL PROTECTED]] [..] >> Quick question. How can I check if the last two characters of a string >> are >> both new line's (i,e, \n) >> >> This is what I have come up with so far: >> >> if ($radentry =~ /"*\n\n/") > > if ( substr( $radentry, -2 ) eq "\n\n" ) I tried to get these to work - and was not able to get them to work.... So I figured, why not test the benchmark of Kevin's idea over and against the two basic 'qr' strategies if ($radentry =~ $regEx){ # Reg or if ($radentry =~ /$regEx/){ # Reg2 or if ($radentry =~ /$regEx/o){ # Reg3 - note the compile once 'o' where my $regEx = qr/\n\n$/; # defined globally in the benchmark and the survey says: [jeeves:~/perl] drieux% perl SillyDoubleNewLine.pl Benchmark: timing 1000000 iterations of Reg, Reg2, Reg3, Regular, Regular1. ... Reg: 3 wallclock secs ( 3.43 usr + 0.00 sys = 3.43 CPU) @ 291545. 19/s (n=1000000) Reg2: 3 wallclock secs ( 3.42 usr + 0.00 sys = 3.42 CPU) @ 292397. 66/s (n=1000000) Reg3: 2 wallclock secs ( 2.98 usr + 0.00 sys = 2.98 CPU) @ 335570. 47/s (n=1000000) Regular: 3 wallclock secs ( 3.04 usr + 0.00 sys = 3.04 CPU) @ 328947. 37/s (n=1000000) Regular1: 2 wallclock secs ( 3.18 usr + 0.00 sys = 3.18 CPU) @ 314465. 41/s (n=1000000) [jeeves:~/perl] drieux% regular1 there is Regular with the '/o' compile once option.... so we are down into the 'scale problem' of what benchmark can handle? Would using Time::HiRes really help us here???? ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]