aboutsummaryrefslogtreecommitdiff
path: root/challenge-029/noud/perl6/ch-2.p6
blob: 9e2e762cfeed90b7b874873d032a8fd7bcab566e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Write a script to demonstrate calling a C function. It could be any user
# defined or standard C function.

# I choose to call my self made ROT13 encryption C function in Perl 6. ROT13
# is a letter subsitution cipher that replaces a letter with the 13th letter
# after it in the alphabet.
#
# To create the shared ROT13 library run: ./make.sh

use NativeCall;

sub rot13(Str) returns Str is native('./rot13.so') {*};

my $enc = rot13("hello perl weekly challenge!");
my $dec = rot13($enc);

say "ROT13 encryption: $enc";
say "ROT13 decryption: $dec";