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