note
Sidhekin
<p> First, since there is no seperator, I would not first look to [doc://split], but rather to m//g in list context: </p>
<c>
my $string = "ThisIsACamelCasedString";
my @split = $string =~ /([A-Z][a-z]*)/g;
print "Parts: @split";
</c>
<p>(This version just skips any part that does not match <c>/[A-Z][a-z]*/</c>; season to taste.)</p>
<p> Dealing with <c>"AStringWithFTP"</c> is trickier, at least without a dictionary. The only heuristic I may suggest is to treat sequences of upper-case characters as a word of its own if in final position or if preceding an uppercase-lowercase sequence:</p>
<c>
my $string = "AStringWithFTPAndHTTP";
my @split = $string =~ /([A-Z](?:[A-Z]*(?=$|[A-Z][a-z])|[a-z]*))/g;
print "Parts: @split";
</c>
<p> That this is a heuristic is clear from noting that <c>"ACString"</c> is split as <c>"AC", "String"</c>, and not as <c>"A", "C", "String"</c>. But frankly, without a dictionary, I don't think there is a real solution. </p>
<p> <b>Update</b>: Oops, pasted the wrong code. Fixed now. Also added prints to make it easier to test that it really <em>is</em> the code I meant to post ...</p>
<p> <b>Update2</b>: Err, pasted the wrong right code too. Sorry, [salva], I did not mean to steal it. /me *blushes* (Fixed now.) </p>
<div class="pmsig"><div class="pmsig-106949">
<p align=center>
<font size=-1><code>print "Just another Perl ${\(trickster and hacker)},"</code></font>
<br>The Sidhekin <b>proves</b> Sidhe did it!</p>
</div></div>
639595
639595