http://qs1969.pair.com?node_id=1030473

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I'm trying to split x.y into (x,y), but if I see something like x.z.y, I want (x.z,y), not (x,z,y). Basically, I always want the string broken up into 2 substrings - everything up to the last period and everything after. I thought that the following would get the job done:
my $str = "x.z.y" my ($first,$second) = split(/\.[^.]*$/,$str)
but perl has fooled me again! Why is this only returning x.z in $first and nothing in $second? Best Regards, Michael