in reply to How do I get what is to the left of my match?

It works for me. The following should give you the same result and seems more readable:
$_="left center right"; m/(.*)(center)(.*)/; print "$1:$2:$3\n";

Replies are listed 'Best First'.
Re: Answer: How do I get what is to the left of my match?
by chipmunk (Parson) on Nov 28, 2000 at 03:29 UTC

    Keep in mind that /(center)/ will match the first occurence of 'center' in the string, while /(.*)(center)(.*)/ will match the last occurence of center (leaving aside for the moment the issue of newlines).

    This might be preferred:
    /(.*?)(center)(.*)/s;
    On the other hand, sometimes using $` et al. is appropriate.