what exactly do you need to escape? (I can never get this straight)

Discussion in 'Perl Misc' started by Steve Grazzini, Jul 16, 2003.

  1. Steve <> wrote:
    > As the topic says, what exactly do you need to escape? I can
    > never get this straight. For instance, I see this line of code
    > when reading through the newsgroups:
    >
    > unlink glob "$jukebox[$i]/$date/*" or die "Cannot unlink files: $!";
    >
    > but I am always escaping the forward slash as \/.


    You never *need* to escape slash. The only time you might want
    to escape it is inside a quote-like operator that has used it for
    the quote-character:

    next if /$jukebox[$i]\/$date/;

    But instead of escaping it there, you'll usually just pick a
    different quote-character.

    next if m|$jukebox[$i]/$date|;

    To answer the more general question:

    The list of what counts as a metacharacter and where is in the
    "Quote and Quote-like Operators" section of perlop.

    % perldoc perlop
    % perldoc -f quotemeta

    --
    Steve
    Steve Grazzini, Jul 16, 2003
    #1
    1. Advertising

  2. Steve Grazzini

    Steve Guest

    Hi all,

    As the topic says, what exactly do you need to escape? I can never get
    this straight. For instance, I see this line of code when reading
    through the newsgroups:

    unlink glob "$jukebox[$i]/$date/*" or die "Cannot unlink files: $!";

    but I am always escaping the forward slash as \/.

    Thanks in advance,

    Steve
    Steve, Jul 16, 2003
    #2
    1. Advertising

  3. Steve Grazzini

    Steve Guest

    Hey, thanks Steve for the info!
    Steve, Jul 17, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Harald Kirsch
    Replies:
    0
    Views:
    320
    Harald Kirsch
    Nov 19, 2004
  2. Soren Kuula
    Replies:
    1
    Views:
    439
    Henry S. Thompson
    Dec 1, 2005
  3. mrw
    Replies:
    4
    Views:
    4,530
    Nils Petter Vaskinn
    Dec 15, 2003
  4. Kevin
    Replies:
    4
    Views:
    410
    Irrwahn Grausewitz
    Oct 17, 2003
  5. Alf P. Steinbach
    Replies:
    6
    Views:
    185
Loading...

Share This Page