in reply to a small regexp question

You can get a list of all matches.
my @all = $string =~ /[^_]+/g;
From that, you can reconstruct a string from it, in whatever way you like. Like, using the default value for $", returns what you seem to want:
my $result = "@all";

Replies are listed 'Best First'.
Re^2: a small regexp question
by blazar (Canon) on Jul 29, 2005 at 10:29 UTC
    This is somewhat closer to what the OP seems to want, since it actually uses a match operator (although not $1 - I wonder if he will consider this to be acceptable!), but then you're using it to match everything that is not an underscore and collect it, in which case as you surely already know split would act the other way round -i.e. more directly- and would be the best tool:
    my @all = split /_+/, $string;