perl code doubt

Discussion in 'Perl Misc' started by siva rajesh, Aug 3, 2005.

  1. siva rajesh

    siva rajesh Guest

    what is the meaning of

    my $DIRDEPTH = "..\\..\\..";

    what is the meaning of \\ and .. in perl?

    thank you
    Rajesh
     
    siva rajesh, Aug 3, 2005
    #1
    1. Advertising

  2. siva rajesh

    Brian Wakem Guest

    Brian Wakem, Aug 3, 2005
    #2
    1. Advertising

  3. siva rajesh

    Paul Lalli Guest

    siva rajesh wrote:
    > Subject: perl code doubt


    Please put the subject of your post in the Subject of your post. Your
    post is not about doubting perl code. Your post is about '\\' and '..'

    > what is the meaning of
    >
    > my $DIRDEPTH = "..\\..\\..";
    >
    > what is the meaning of \\ and .. in perl?


    In a normal string, .. has no special meaning of any kind. Those are
    simply two periods.

    The \ is a special character. It starts an escape sequence. It makes
    non-special characters special (for example, a \n means "newline"). It
    also makes special characters non-special. In this case, the first \
    is used to make the second \ non-special. Therefore, "\\" simply means
    a single backslash.

    The above string looks to be a directory location, going three levels
    up from the current directory.

    If you post some more context, we can probably help you figure out what
    the specific chunk of code is actually doing.

    Paul Lalli
     
    Paul Lalli, Aug 3, 2005
    #3
  4. siva rajesh wrote:
    > what is the meaning of
    >
    > my $DIRDEPTH = "..\\..\\..";
    >
    > what is the meaning of \\ and .. in perl?


    Everything between quotes (") are string characters. The \ character is
    special in a double quoted string in that it and the character following
    it represent either a meta-character ( \n, \t, \b, etc. ) or the
    character itself.

    perldoc perlop


    John
    --
    use Perl;
    program
    fulfillment
     
    John W. Krahn, Aug 3, 2005
    #4
  5. siva rajesh

    Tintin Guest

    "siva rajesh" <> wrote in message
    news:...
    > what is the meaning of
    >
    > my $DIRDEPTH = "..\\..\\..";
    >
    > what is the meaning of \\ and .. in perl?


    same as writing

    my $DIRDEPTH = '..\..\..';
     
    Tintin, Aug 4, 2005
    #5
  6. siva rajesh

    Big and Blue Guest

    Paul Lalli wrote:
    >
    >>what is the meaning of
    >>
    >>my $DIRDEPTH = "..\\..\\..";

    >
    > The above string looks to be a directory location, going three levels
    > up from the current directory.


    Only on MS Windows.

    On Unix it would refer to an entry called '..\..\..', which is a valid,
    albeit unusual, filename.

    It might be better written as:

    my $DIRDEPTH = "../../..";

    which would refer to 3-levels up on Windows, Unix (and MacOSX), and avoid
    the reader having to work out that "\\" is actually '\'.


    --
    Just because I've written it doesn't mean that
    either you or I have to believe it.
     
    Big and Blue, Aug 11, 2005
    #6
    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. Babu
    Replies:
    1
    Views:
    2,919
    Jim Gibson
    Mar 10, 2005
  2. Bob Nelson

    doubt about doubt

    Bob Nelson, Jul 28, 2006, in forum: C Programming
    Replies:
    11
    Views:
    629
  3. Replies:
    0
    Views:
    566
  4. Peter Otten
    Replies:
    2
    Views:
    119
    Cousin Stanley
    Aug 10, 2013
  5. Terry Reedy
    Replies:
    0
    Views:
    120
    Terry Reedy
    Aug 10, 2013
Loading...

Share This Page