use warnings; use strict; my $thing = 'foo/bar/goo'; my ($stuff) = $thing =~ m{^([^/]*)}; print "$stuff\n"; __END__ foo