Hi,

I have a $string that is separated by , and space;

boy, pig, 123, 123:412adbd, d0g, lajdlf134><<_ lkadsf !234,


Now I want to capture the string(s) between last two commas. It consists of 
anything upto 32 characters. that is, right after d0g,\s+ up to the last 
character before the last comma at the end of the line.

if I do something like

(my $value) = $_ ~= /,\s+(.*),\s+$/;

$value would start matching from "pig" because when I used $ and it looked 
back, the first thing it would match is ", pig.... upto the end of the line"

I wonder how you could match only the pattern which is nearest to the end of 
the line having used $ anchor.

To get around this, I could split the lines push each comma delimited string 
into an array and finally print the last element which is a lot of work to do.

Is there some sort of turning of greedy behavior of the $ anchor?














      

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to