Help Required !!!!

Discussion in 'Perl Misc' started by vandana, Jun 23, 2006.

  1. vandana

    vandana Guest

    Hello,

    # strip (trailing) filename from path, leaving directory only

    my ($path) = $ENV{'PATH_TRANSLATED'} =~ m|(^.*)\\|;

    It removes trailing filename from path. Can anyone help me to
    understand the working of
    m|(^.*)\\|; in above command.

    Regards
    Vandana
    vandana, Jun 23, 2006
    #1
    1. Advertising

  2. vandana

    David Squire Guest

    vandana wrote:
    > Hello,


    Hello Vandana,

    Welcome to this group. Might I suggest that a good starting point for
    you would be to read the posting guidelines that are posted here several
    times a week. In particular, they give advice on how to maximize your
    chances of getting a useful response, by doing such things are using a
    meaningful subject line for your post.


    >
    > # strip (trailing) filename from path, leaving directory only
    >
    > my ($path) = $ENV{'PATH_TRANSLATED'} =~ m|(^.*)\\|;
    >
    > It removes trailing filename from path. Can anyone help me to
    > understand the working of
    > m|(^.*)\\|; in above command.


    You need to read Perl's documentation on regular expressions, and the
    match and substitution operators that use them. Perl comes with its
    documentation included. You can access it using the perldoc command on
    the command line. Try "perldoc perlre", "perldoc perlop", and "perldoc
    perlretut". You can also read the documentation online at
    http://www.perl.com/pub/q/documentation

    Regards,

    DS
    David Squire, Jun 23, 2006
    #2
    1. Advertising

  3. vandana

    Guest

    vandana wrote:
    > Hello,
    > It removes trailing filename from path. Can anyone help me to
    > understand the working of
    > m|(^.*)\\|; in above command.


    m # matches the left value
    | # the delimiter for the regular expression
    ( # beginning of whatever is saved
    ^ # matches the beginning of the line
    .. # matches any character up to whatever follows
    * # matches greedily any number of characters from zero upward
    ) # ends the recording of charachter - paired with the opening parens
    \ # the escape character
    \ # the character escaped, possibly a Windows path delimiter
    | # the delimiter of the regular expression - paired with the opening
    pipe
    ; # ends the expression

    Suggest you sit down with the Perl documentation and read the pages on
    regular expressions.

    CC
    , Jun 23, 2006
    #3
  4. vandana wrote:
    >
    > # strip (trailing) filename from path, leaving directory only


    You probably want to use the File::Basename::dirname function for that:

    perldoc File::Basename


    John
    --
    use Perl;
    program
    fulfillment
    John W. Krahn, Jun 23, 2006
    #4
  5. vandana wrote:

    Please put the subject of your post into the Subject of your post

    > # strip (trailing) filename from path, leaving directory only


    There are ready-made modules for that task (See File::Basename) which are
    tried and proven and work regardless of the platform used.

    > my ($path) = $ENV{'PATH_TRANSLATED'} =~ m|(^.*)\\|;
    >
    > It removes trailing filename from path.
    > Can anyone help me to
    > understand the working of
    > m|(^.*)\\|; in above command.


    See perldoc perlop for the 'm' operator.
    See perldoc perlretut and perldoc perlre for the RE.

    jue
    Jürgen Exner, Jun 23, 2006
    #5
  6. vandana

    Guest

    vandana wrote:
    > Subject: Help Required !!!!!


    Help is required... It's optional...
    , Jun 23, 2006
    #6
  7. vandana <> wrote:

    > Subject: Help Required !!!!



    You will get more people to help if you compose a meaningful
    Subject line.

    Every post here requires help. Do you think that question-answerers
    read every post? They don't. They read the ones with interesting
    subjects, which your's isn't.

    Please see the Posting Guidelines that are posted here frequently.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Jun 23, 2006
    #7
    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. Dinesh Upare

    help required urgent

    Dinesh Upare, Aug 13, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,005
    Carl Prothman [MVP]
    Aug 13, 2003
  2. Kashif
    Replies:
    6
    Views:
    540
    Kashif
    Nov 29, 2005
  3. SenthilVel

    Help Required for Help Context Id !!!!!!

    SenthilVel, Nov 30, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    3,135
    SenthilVel
    Dec 14, 2005
  4. Just D.
    Replies:
    0
    Views:
    446
    Just D.
    Mar 10, 2006
  5. Emiliano
    Replies:
    2
    Views:
    322
    Rajesh.V
    Oct 16, 2003
Loading...

Share This Page