From: Phlip Date: 2008-07-28T03:24:45+09:00 Subject: Re: head/tail split for path Bill Walton wrote: > You could do like this. > > def head_tail_split(fname) > components = fname.split('/') > [components.shirt, components.join('/')] > end > > irb(main):001:0> fname = 'home/foo/bar' > => "home/foo/bar" > irb(main):002:0> components = fname.split('/') > => ["home", "foo", "bar"] > irb(main):003:0> [components.shift, components.join('/')] > => ["home", "foo/bar"] That would be safer if fname were a Pathname. But then, would split only split off the last path part? Or the first? If the last, how could we roll many splits up, then pop the first? -- Phlip