Re: When would you use qr// on a literal string?
- From: Tad McClellan <tadmc@xxxxxxxxxxxxxx>
- Date: Mon, 17 Jul 2006 10:33:08 -0500
it_says_BALLS_on_your forehead <simon.chao@xxxxxxx> wrote:
I thought that qr was mainly used for pre-compiling variables into
regex patterns, but a colleague uses it like so:
my ( $name, $value ) = split qr/=/, $string;
Are there any benefits to doing this?
Not that I can see.
He claims that the use of the
qr// op here can help capture an error if the STRING is not a valid
regex.
I have no idea what "capture an error" might mean...
Does this make any sense?
No, unless he can give an example where using qr// gives more
info than an m// with the same pattern.
These both make the same output for instance.
perl -e 'qr/(/'
and
perl -e 'm/(/'
Can your colleague provide a counter-example that shows qr// as
somehow "better"?
--
Tad McClellan SGML consulting
tadmc@xxxxxxxxxxxxxx Perl programming
Fort Worth, Texas
.
- References:
- When would you use qr// on a literal string?
- From: it_says_BALLS_on_your forehead
- When would you use qr// on a literal string?
- Prev by Date: Re: When would you use qr// on a literal string?
- Next by Date: Re: Perl integrating with PHP
- Previous by thread: Re: When would you use qr// on a literal string?
- Next by thread: why is perl -e 'unlink(glob("*"))' so much faster than rm ?
- Index(es):
Relevant Pages
|
|