kluther has asked for the wisdom of the Perl Monks concerning the following question:
The problem:
Find pieces of text in a file enclosed by `@` and replace the inside
Input:
@abc@ abc @ABC@
cba @cba CBA@
Deisred output:
абц abc АБЦ
cba цба ЦБА
I have the following:
Thanks for help in advance!
Kluther
Find pieces of text in a file enclosed by `@` and replace the inside
Input:
@abc@ abc @ABC@
cba @cba CBA@
Deisred output:
абц abc АБЦ
cba цба ЦБА
I have the following:
But I'm stuck on how to process further#!/usr/bin/perl use strict; use warnings; use Encode; my $output; open FILE,"<", 'test.txt'; while (<FILE>) { chomp(my @chars = split(//, $_)); for (@chars) { my @char; $_ =~ s/a/chr(0x430)/eg; $_ =~ s/b/chr(0x431)/eg; $_ =~ s/c/chr(0x446)/eg; $_ =~ s/d/chr(0x434)/eg; $_ =~ s/e/chr(0x435)/eg; $_ =~ s/A/chr(0x410)/eg; $_ =~ s/B/chr(0x411)/eg; $_ =~ s/C/chr(0x426)/eg; push @char, $_; $output = join "", @char; print encode("utf-8",$output);} print "\n"; } close FILE;
Thanks for help in advance!
Kluther
|
---|
Back to
Seekers of Perl Wisdom