http://www.perlmonks.org?node_id=268935


in reply to Re: Find Comma in a string
in thread Find Comma in a string

++tomte for a good answer.

I'd change the example a little. The quoting style used makes this one-liner hard to read - it forces backlashes where they aren't expected. With a *nix shell, single quotes won't force you to escape the dollar signs, ie:

$> perl -e '$pos = 0;print ($pos . " ") while(($pos = index("joe,is,at,home", ",", $pos+1)) != -1);' 3 6 9