in reply to Re: Guess I don't have \Q and \E figured out yet...
in thread Guess I don't have \Q and \E figured out yet...

OK, that seems clear hdp, but I'm confused by the following snippet (using \t instead of \a for visibility) in which perlfunc:quotemeta appears to behave differently than /Q/E:
$foo = "\tfoo"; $_ = ">>ha<<\n"; s/ha/$foo/; print; $_ = ">>ha<<\n"; s/ha/\Q$foo\E/; print; quotemeta $foo; # update: this is doing nothing! $_ = ">>ha<<\n"; s/ha/$foo/; print; $foo = '\tfoo'; $_ = ">>ha<<\n"; s/ha/$foo/; print; $_ = ">>ha<<\n"; s/ha/\Q$foo\E/; print; quotemeta $foo; # update: this is doing nothing! $_ = ">>ha<<\n"; s/ha/$foo/; print;
which produces:
>> foo<< >>\ foo<< >> foo<< >>\tfoo<< >>\\tfoo<< >>\tfoo<<
What am I forgetting here?

Update Aarghhh! How bloody embarrassing! Thanks tye, that's what I get for minimizing my keystrokes!
Useless use of quotemeta in void context at D:\Perl\tmp\quotemeta.pl line 9.
Useless use of quotemeta in void context at D:\Perl\tmp\quotemeta.pl line 15.
/me smacks himself in the forehead

--
I'd like to be able to assign to an luser

Replies are listed 'Best First'.
(tye)Re: \Q and \E vs. quotemeta?
by tye (Sage) on Apr 30, 2001 at 20:52 UTC
    $foo= '\t\a\b\c'; print "foo=($foo)\n"; quotemeta $foo; print "foo=($foo)\n"; $foo= quotemeta $foo; print "foo=($foo)\n"; __END__ Produces: foo=(\t\a\b\c) foo=(\t\a\b\c) foo=(\\t\\a\\b\\c)

    That is, quotemeta doesn't modify in place, it returns a modified value so your uses of quotemeta are useless.

    If you had turned on warnings, then you would have been told: Useless use of quotemeta in void context at quotemeta.pl line 5. which is why we often urge people to do stuff like that. q-:

            - tye (but my friends call me "Tye")