Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/env perl
- # Source characters
- my @S = qw(p t t͡ʃ k s ʃ);
- # Replacement characters
- my @Z = qw(b d d͡ʒ g z ʒ);
- # Boundaries
- my $V = "a|ə|e|o|i|u|ø|y";
- use warnings;
- use strict;
- my $filename = pop;
- my $inverted = 0;
- while ( $_ = shift )
- {
- if(/--invert/)
- {
- $inverted = 1;
- }
- }
- # Open the file
- open(my $fh, "<", $filename);
- # Read line by line
- while(<$fh>)
- {
- # apply early transformations here
- # Go through each "source" => "replacement"
- for(my $i = 0; $i < @S; $i++) {
- # retrieve the source
- my $item = $inverted?$Z[$i]:$S[$i];
- # and replacement
- my $rplc = $inverted?$S[$i]:$Z[$i];
- # replace the source by replacement inside the boundaries
- s/((?:$V)+)$item((?:$V)+)/$1$rplc$2/gi
- }
- # insert any other transformations here
- # print the line after modifications
- print;
- }
- close($fh);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement