nr0mx has asked for the wisdom of the Perl Monks concerning the following question:
Specifically, I am talking about the code pasted below. The perlop entry talks about qr() in the same breath as q(),qq(),qx(),etc and Programming Perl has this to say about them -
"Some of these are simply forms of "syntactic sugar" to let you avoid putting too many backslashes into quoted strings. Any non-alphanumeric, non-whitespace delimiter can be used in place of /. If the delimiters are single quotes, no variable interpolation is done on the pattern. If the opening delimiter is a parenthesis, bracket, brace, or angle bracket, the closing delimiter will be the matching construct."
Am I missing something here ?
use strict; use diagnostics; use Getopt::Long; my ( $timing ) = 0 ; my $regexp = qr(\s+execution\s+time\s+\(\s+millis\s+\)\s+\:\s+); while(<DATA>) { chomp; do { ( $timing ) = /$regexp(\d+)/; print "$timing "; }if /$regexp/; } print "Done!\n"; __DATA__ PPP execution time ( millis ) : 1062 PPP execution time ( millis ) : 6460 PPP execution time ( millis ) : 7570 PPP execution time ( millis ) : 38646 PPP execution time ( millis ) : 45658 PPP execution time ( millis ) : 577
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: qr delimiter question
by Jenda (Abbot) on Nov 17, 2003 at 16:27 UTC | |
|
Re: qr delimiter question
by Anonymous Monk on Nov 17, 2003 at 16:25 UTC | |
|
Re: qr delimiter question
by broquaint (Abbot) on Nov 17, 2003 at 16:29 UTC | |
|
Re: qr delimiter question
by EvdB (Deacon) on Nov 17, 2003 at 16:26 UTC | |
|
Re: qr delimiter question
by ysth (Canon) on Nov 17, 2003 at 17:27 UTC | |
by Roy Johnson (Monsignor) on Nov 17, 2003 at 18:21 UTC |