c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "use 5.010; ;; my $equation = '979x + 87y - 8723z = 274320'; my @parts = $equation =~ m{ \G (?| (.*?)([xyz]) | (.*) = (.*) \z) }xmsig; dd \@parts; " [979, "x", " + 87", "y", " - 8723", "z", " ", " 274320"]