Bart Lateur wrote: > > When thinking of a user-friendly interface to let a user define a table > of words and their hyphenated forms, I stumbled across this cute > problem. It's simple enough to be a fun puzzle, yet not too hard to be > labour. It might even be a fun task for Perl Golf. > > The problem is this: given two versions of a word, one without, and one > with hyphenation, determine which hyphens are soft hyphens (optional > breakpoints), and which ones are hard hyphens? For example: > > hypo-allergeen hy-po-al-ler-geen > > (If you wonder about the hyphenation rules: Dutch) >
how about?: my $hard = 'hypo-allergeen'; my $soft = 'hy-po-al-ler-geen'; while ($soft =~/-/g) { my $pre = $`; $hard =~ s/$pre(-?)/ print "$pre- is ", $1 ? 'hard' : 'soft'; "$pre-" /e; } results: [jmccrea@bit jmccrea]$ perl -l testy hy- is soft hy-po- is hard hy-po-al- is soft hy-po-al-ler- is soft Jasper ps Bart, sorry about reply-to (and see if you can spot the error I fixed in here) -- It's like, how much more black could this be? and the answer is none. None more black.