On Mon, 11 Oct 2004 13:13:37 -0600, Wiggins d Anconia <[EMAIL PROTECTED]> wrote: > > the following is an as yet incomplete regex that i'm working on: > > > > $data = $_ =~ > > s/<(name)>(.*?)<(desc)>(.*?)<(copy)>(.*?)<(license)>(.*?)<(entry)>//xg > >
Are you thinking of : ( $a1,$b1,$a2,$b2,$a3,$b3,$a4,$b4,$a5,$b5 ) = $_ =~ /regexp/ ? The result of a regexp ($1..$9) are returned in array context, so you can either assign them to an array @data = $_ =~ /regexp/ or return them to named variables as above. I use the above, because I can't stand using '$1' '$2' '$3' etc for more than two lines of code below the regexp capture, because context is lost to the reader. > > > > every other capture ($1 $3 $5 $7 $9) is going to be used one way, the > > other > > captures will be used differently... i'm wondering if there's a way to > > force the captures into particular numbered variable, so that > > $1 =$1 > > $2 = $3 > > $3 = $5 > > $4 = $7 > > $5 = $9 > > > > How about just not capturing them to begin with? If you add C<?:> to > the beginning of your capture it will ignore the capture. Having said > that, why are you capturing to begin with if you are just going to throw > them away? The parens in your example don't matter for the match to work. > > > etc... or is it even worth it for easier coding later on? > > > > At the very least I would switch to named variables to make it more > readable and prevent the chance that they get clobbered by a later regex. > > http://danconia.org > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>