my $thing = 'foo/bar/goo'; ( my $stuff ) = ( $thing =~ m{ # Quote-like characters are now {}. ^ # Match at the start of the string. ( [^/]+ ) # Capture everything in the set of all # characters that are not '/' }x # Close the regexp. x modifier allows # freeform (as in non-significant # whitespace). ); print "$stuff\n";