in reply to Re: Escaping confusion in RE...
in thread Escaping confusion in RE...

I didn't give enough context. My bad. The substitution does seem to work. Here's more context, and the error.
while ( @file ) { s#l:\\Data\\([0-9]*)\\#D:\\Sites\\$1\\Data\\#i; print; }
@file is filled with many lines like so: my @file = <FILE>;

Here are the warnings:
Use of uninitialized value in print at foo.pl line 44. Use of uninitialized value in substitution (s///) at foo.pl line 43. Use of uninitialized value in substitution (s///) at foo.pl line 43.

-------------------------------------
Nothing is too wonderful to be true
-- Michael Faraday

Replies are listed 'Best First'.
Re^3: Escaping confusion in RE...
by runrig (Abbot) on Jul 05, 2007 at 22:40 UTC
    If @file is an array then you want a for loop, not a while loop. If you want to read lines from a file into $_ then you want while ( <FILE> ) {

    I.e., you do have an infinite loop, @file has a constant number of things in it, so it is always true, unless you shift or pop things from it in the loop. (but a for loop is probably more appropriate).

Re^3:Escaping confusion in RE...
by toolic (Bishop) on Jul 06, 2007 at 00:36 UTC
    ([0-9]*) will match zero or more digits.

    To be a little cleaner, you probably should match 1 or more digits using ([0-9]+)