Bifid cipher: Difference between revisions

Content added Content deleted
m (→‎{{header|Perl}}: consolidate two lists into a single array)
m (→‎{{header|Perl}}: additional polishing)
Line 187: Line 187:
for my($k,$v) (%P) { $I{$v} = $k }
for my($k,$v) (%P) { $I{$v} = $k }
for my ($n,$char) (indexed split '', ($text =~ s/\s//gr)) {
for my ($n,$char) (indexed split '', ($text =~ s/\s//gr)) {
for my($i,$j) (split ' ', $P{$char}) { $c[0][$n] = $i; $c[1][$n] = $j }
for my($m,$i) (indexed split ' ', $P{$char}) { $c[$m][$n] = $i }
}
}
for my($i,$j) (@c[1]->@*, @c[0]->@*) { $encrypted .= $I{"$j $i"} }
for my($i,$j) ($c[1]->@*, $c[0]->@*) { $encrypted .= $I{"$j $i"} }
$encrypted
$encrypted
}
}