almaric has asked for the wisdom of the Perl Monks concerning the following question:
This prints$a="a "; foreach (1..(length $a)) { print "a(".$1.")(".$2.")\n" if ( $a =~ m/^a( {$_})( )/ ) ; }
Does anyone know a way to write a single regexp ($regexp) that results in the same output when inserted into the following code?a( )( ) a( )( ) a( )( )
Thanks for any help$a="a "; while ( $a =~ m/$regexp/ ) { # or m//g, m//gc, ... print "a(".$1.")(".$2.")\n"; }
regards,
almaric
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: With one regexp
by BrowserUk (Patriarch) on Feb 29, 2004 at 12:49 UTC |