in reply to question on perl's split function
Also: moritz is right, that /* matches 0 or more slashes, so it would also split the string where you wouldn't expect it to split the string. Simply try using the following string with your split regex of /*:my $string = "///a/b////c"; my @arr = grep {$_ ne ''} split("\/+",$string); print ":" , join("_",@arr) , ":\n";
then you'll understand the problem. + is what you need as it matches 1..n ocurrences of the previous char.my $string = "//foo//bar///";
|
|---|