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:
but perl has fooled me again! Why is this only returning x.z in $first and nothing in $second? Best Regards, Michaelmy $str = "x.z.y" my ($first,$second) = split(/\.[^.]*$/,$str)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: split giving me a splitting headache
by toolic (Bishop) on Apr 24, 2013 at 18:37 UTC | |
by Anonymous Monk on Apr 24, 2013 at 18:40 UTC | |
Re: split giving me a splitting headache
by BrowserUk (Patriarch) on Apr 24, 2013 at 18:41 UTC | |
Re: split giving me a splitting headache
by kennethk (Abbot) on Apr 24, 2013 at 19:04 UTC | |
Re: split giving me a splitting headache
by Your Mother (Archbishop) on Apr 24, 2013 at 18:45 UTC | |
Re: split giving me a splitting headache
by bart (Canon) on Apr 24, 2013 at 19:21 UTC | |
Re: split giving me a splitting headache
by hdb (Monsignor) on Apr 25, 2013 at 05:24 UTC | |
split without using split
by space_monk (Chaplain) on Apr 24, 2013 at 19:22 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |
Back to
Seekers of Perl Wisdom