How about:

 map s|\B|"|g, @ARGV;
 $_ = shift | shift;
 s|"||g;
 s|/|­|g;
 print "$_\n";

tilrman:~$ ./hyph.pl hypo-allergeen hy-po-al-ler-geen
hy­po-al­ler­geen

LP^>

On Thu, Sep 05, 2002 at 04:36:12PM +0200, Bart Lateur wrote:
> On Thu, 05 Sep 2002 15:04:30 +0200, Bart Lateur wrote:
> 
> >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
> 
> My own attempt:
> 
>       @ARGV = qw(hypo-allergeen hy-po-al-ler-geen);
> 
>       my($word, $split) = @ARGV;
>       $split =~ s/-|(\W)/$1 ? "\\$1" : '(-?)'/ge;
>       $word =~ /^$split$/ or die "No match";
>       for(my $i = @-; --$i > 0;) {
>           next if $+[$i] > $-[$i];
>           substr($word, $-[$i], 0) = '­';
>       }
>       print $word;
> -->
>       hy­po-al­ler­geen
> 
> -- 
>       Bart.

Reply via email to