In the following program, I want the regex to always match what's to the left of the alternation operator ($larry) before matching 'default'. Because of the leftmost rule, this doesn't happen; in the second case, 'default' matches because it appears earlier in the string. How can I modify the regex so that the first match prints 'foo' and the second match prints 'bar'?
Thanks for your help. #!/usr/bin/perl -w use strict; my ($larry, $match); my ($str) = <<EOQ; foo default bar EOQ $larry = 'foo'; ($match) = $str =~ /($larry|default)/; print "$match\n"; # prints foo $larry = 'bar'; ($match) = $str =~ /($larry|default)/; print "$match\n"; # prints default __END__ Shimon Bollinger [EMAIL PROTECTED] 054-530-0515 02/621-8032 What are you bringing the book I want to be read to out of about Down Under up for? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>