Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > RegEx: odd number of slashes? and too many slashes?

Reply
Thread Tools

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

 
 
Dan Wilkin
Guest
Posts: n/a
 
      07-17-2006
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
 
Reply With Quote
 
 
 
 
robic0
Guest
Posts: n/a
 
      07-17-2006
On Mon, 17 Jul 2006 03:20:44 GMT, Dan Wilkin <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how many hard drives is too many? mattcar Computer Support 6 06-29-2007 01:58 AM
How many warnings is too many? Rhino Java 33 12-22-2005 09:39 PM
How many threads are too many? rbt Python 1 06-11-2005 11:03 PM
How many threads is too many? peelman Java 12 01-15-2005 07:37 AM
Too many (small) vs. too large linked script files in a document... Dag Sunde Javascript 4 12-16-2004 11:38 PM



Advertisments