RegEx: odd number of slashes? and too many slashes?

Discussion in 'Perl Misc' started by Dan Wilkin, Jul 17, 2006.

  1. Dan Wilkin

    Dan Wilkin Guest

    Why does the following code work to find the literal UNC path specified.
    altPath should have worked, right? It looks like the regex engine is
    gobbling up slashes!! Perl 5.x


    #my $altPath = '\\\\websrv\\VMServer\\cvs\\SAMS\\archives';
    my $rootPath = '\\\\\\\websrv\\\VMServer\\\cvs\\\SAMS\\\archives';

    # load the list of obsolete files
    sub loadObsoletes {
    my $i = 0;
    my $line;
    open SRC, $src_name or die "Can't open file '$src_name'";
    while (<SRC>) {
    chomp;
    /$rootPath(.+?)-arc - (.+)/o; # extract the filenames
    into an array
    print "Matched: <$`> $& <$'>\n";
    print "Parsed line $i as: {$1}{$2}\n" if $verbose;
    $line = $1;
    $line =~ s[\\][/]g;
    print "Subst as: {$line}\n" if $verbose;
    $LoF[$i] = $line;
    $i++;
    }
    close SRC;
    print "Listed source file as: @LoF" if $verbose;
    }


    Thnx,
    Dan
     
    Dan Wilkin, Jul 17, 2006
    #1
    1. Advertising

  2. Dan Wilkin

    robic0 Guest

    On Mon, 17 Jul 2006 03:20:44 GMT, Dan Wilkin <> wrote:

    >Why does the following code work to find the literal UNC path specified.
    > altPath should have worked, right? It looks like the regex engine is
    >gobbling up slashes!! Perl 5.x
    >
    >
    >#my $altPath = '\\\\websrv\\VMServer\\cvs\\SAMS\\archives';
    >my $rootPath = '\\\\\\\websrv\\\VMServer\\\cvs\\\SAMS\\\archives';
    >
    ># load the list of obsolete files
    >sub loadObsoletes {
    > my $i = 0;
    > my $line;
    > open SRC, $src_name or die "Can't open file '$src_name'";
    > while (<SRC>) {
    > chomp;
    > /$rootPath(.+?)-arc - (.+)/o; # extract the filenames
    >into an array
    > print "Matched: <$`> $& <$'>\n";
    > print "Parsed line $i as: {$1}{$2}\n" if $verbose;
    > $line = $1;
    > $line =~ s[\\][/]g;
    > print "Subst as: {$line}\n" if $verbose;
    > $LoF[$i] = $line;
    > $i++;
    > }
    > close SRC;
    > print "Listed source file as: @LoF" if $verbose;
    >}
    >
    >
    >Thnx,
    >Dan


    U tell me. If you don't understand "in solution" then you can't post here

    robic0
     
    robic0, Jul 17, 2006
    #2
    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. qazmlp
    Replies:
    5
    Views:
    699
    Michael Dunn
    Apr 7, 2004
  2. peelman

    How many threads is too many?

    peelman, Jan 13, 2005, in forum: Java
    Replies:
    12
    Views:
    857
    Esmond Pitt
    Jan 15, 2005
  3. Rhino
    Replies:
    33
    Views:
    1,334
    Oliver Wong
    Dec 22, 2005
  4. rbt
    Replies:
    1
    Views:
    364
  5. Dag Sunde
    Replies:
    4
    Views:
    372
Loading...

Share This Page