Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use Term::ANSIColor;
- sub string_to_binary {
- my $input_string = shift;
- my $binary_representation = unpack("B*", $input_string);
- return $binary_representation;
- }
- print color('bold blue');
- print "Masukkan string yang ingin diubah ke representasi biner: ";
- print color('reset');
- my $user_input = <STDIN>;
- chomp($user_input);
- my $binary_result = string_to_binary($user_input);
- print color('bold yellow');
- print "Representasi Biner dari string '$user_input': 0b$binary_result\n";
- print color('reset');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement