develooper Front page | perl.perl5.porters | Postings from July 2000

quotemeta

Thread Next
From:
Jerrad Pierce
Date:
July 25, 2000 13:28
Subject:
quotemeta
Message ID:
200007252029.QAA10897@cab-calloway.mit.edu
%perldoc quotemeta
=item quotemeta EXPR

=item quotemeta

Returns the value of EXPR with all non-alphanumeric
characters backslashed.  (That is, all characters not matching
C</[A-Za-z_0-9]/> will be preceded by a backslash in the
returned string, regardless of any locale settings.)
This is the internal function implementing
the C<\Q> escape in double-quoted strings.

If EXPR is omitted, uses C<$_>.

%perl
print $_ = quotemeta("/var/../\0tmp\n");
eval(print $_);
^D
\/var\/\.\.\/\tmp
\/var\/\.\.\/\tmp

Now is this a feature, or what? The resulting string is rather different
from the input. I don't remember embedding any tabs...

Okay, so it's not really a tab. (un)fortunately perl does seem to be
protecting the resulting string. But this doesn't seem right...
I'd have expected either:
\/var\/\.\.\/tmp	OR	\/var\/\.\.\/\0tmp

At the very least shouldn't the dox indicate that null is a special case?
Are there any others?
--  
                                                  *             __    *      .
           \     |     /           .        . .           .  . ((_
               _____                       .                         .     .
          --  /     \  --           .        .      .   +    .   .     _/\
      oooooooooo.   |               * .       .   .           *       / ;M\_ .
   .oooooooooooo.oo.                  .  .    .       . /\    .      /  :IMM\
  ..oooooooooooo..oo.   Jerrad Pierce              /\  /  \         /   ;IIWMM
  ..oooooooooo.......   209 North Street     +    /  \ /  \  .     /   ;IIIIWM
  ...ooooooooo.......   Randolph, MA 02368        /  \     \  ___/   :;IIIIIWM
  ....ooo....o.......                            /    \    \ /  ::     ;;IIIMI
   .....ooo.........    http://www.pthbb.org     /    \     \   :     :::;IIIM
     ..ooooooo....      __________________________ ||   ||       ::.....::::::
MOTD on Sweetmorn, the 60th of Confusion, in the YOLD 3166:

If you have tears shed them now

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About