in reply to Re: using a variable as a filehandle
in thread using a variable as a filehandle

this worked perfectly thanks. I just have a question about how it works? it seems like the assigments of $1 remove that section from the original variable. is that correct? can someone explain how that works in order to keep the pointer for the while in the correct place.

thanks soo much you were all a great help!

Replies are listed 'Best First'.
Re^3: using a variable as a filehandle
by ikegami (Patriarch) on Nov 01, 2004 at 20:06 UTC
    Not quite. The g forces subsequent calls to the regexp to match from somewhere after the previous match ended, until no match is found.
    print("$1:") while ('abcdefgh' =~ /(.)/g); a:b:c:d:e:f:g:h: print("$1:") while ('vowels' =~ /([aeiou])/g); o:e:

    \G is similiar to ^, but refers to where the last match left off.

    print("$1:") while ('oiseau' =~ /\G([aeiou])/g); o:i: