#!/usr/bin/perl use strict; use warnings; use 5.010001; my $input; say "Please Enter String a string to be encrypted or decrypted"; $input = <>; chomp $input; my @ascii_char; my $char; while($input =~ m/(.)/g) { push @ascii_char, ord $1; } say @ascii_char; open my $ENCRYPTED_STRING, '>', \my $encrypted_string; foreach( @ascii_char ) { if ($_ >= 97 and $_ <= 122) { if ((122 - $_) <13 ){ $_ = 97 + (13 - (123 - $_)); } else { $_ += 13; } } elsif ($_ >= 65 and $_ <= 90) { if ((90 - $_) < 13 ){ $_ = 65 + (13 - (91 - $_)); } else { $_ += 13; } } print $ENCRYPTED_STRING chr; } close $ENCRYPTED_STRING; say $encrypted_string;