On 8/21/07, Dr.Ruud <[EMAIL PROTECTED]> wrote: > Jeff Pang schreef: > > Christopher Spears: > > >> print "Enter regular expression: "; > >> chomp(my $regexp = <STDIN>); > > > > $regexp = quotemeta($regexp); > > Since it specifically asks for a regular expression, I would definitely > not do quotemeta(). > >
Exactly. quotemeta() defeats the whole purpose here. We *want* the user to be able to input metacharacters for the match. > >> #print $regexp; > > Make that > > print qr/$regexp/; > Not sure where your headed with this. First, OP wants to print the input back to the user. it makes sense to do this unmodified, for the most part. Also, qr// doesn't modify the variable, it returns the compiled expression, which is just being thrown away after the print. That means the regex is actually being compiled twice. It probably doesn't, though, make sense to compile the regex before entering the loop, so perhaps something like: chomp(my $regexp = <STDIN>); print $regexp, "\n"; $regexp = qr/$regexp/; ... One additional note to Chris: In any case, '$_ =~ \$regxep' is almost certainly not what you're looking for. Since $regexp is a simple scalar and not a reference, your current code is trying to match against something like /SCALAR(0x18231cc)/. HTH, --jay -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org values of β will give rise to dom!