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


in reply to Regex to get everything before first /

my ($stuff) = $thing =~ m{^([^/]*)};
my ($stuff) = $thing =~ m{^(.*?)/}s;
my ($stuff) = split(qr{/}, $thing, 2);
my ($stuff) = split(qr{/}, $thing);

The second requires the presence of a "/", and uses the non-greedy modifier which I prefer to avoid.