Results 1 to 3 of 3

Thread: Easy Perl Question

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Location
    everywhere
    Posts
    111

    Easy Perl Question

    I am new to Perl and I'm finding out I'm pretty bad with manipulating text

    Anyways, I have a string like this that I retrieved from our CVS log:
    \\corpfiler1\Unix\u\srcroot\acapi\src/winioctl.h

    and I need to put all the slashes the same way and cut off the file name, so I need in a different variable, something that looks like this...

    \\corpfiler1\Unix\u\srcroot\acapi\src\

    How can I do that?

    Thanks in advance,

    Jacob438

  2. #2
    New Member
    Join Date
    Dec 2002
    Location
    Madison Wisconsin
    Posts
    7
    Using reguar expression if varName contains the log entry...
    varName =~ s/\\/\//;

    That will change the slash in your example the right way. This is the most cryptic part of Perl. After that you simply look for the last occurance of a "\" character. Then substring out from position 0 to the position of the last "\".

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Location
    everywhere
    Posts
    111
    cool thanks! Yeah, perl seems to get quite cryptic with this kind of stuff and sometimes it is confusing to look at, but that advice pointed me in the right direction, thanks!

    Jacob438

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width