Skip to content

Instantly share code, notes, and snippets.

@dgags
Created May 19, 2017
Embed
What would you like to do?
Daily Programmer - phillydevslack
#!/usr/bin/perl -W
#
use strict;
sub is_hex {
my ($s) = @_;
local $SIG{__WARN__} = sub { die };
return eval { scalar hex $s; 1 };
}
my $string = "Taylor Swift put out the album 7C5 in 7DE";
foreach my $word ( split / /, $string) {
unless (is_hex($word)) {
print "$word ";
} else {
print hex($word) . " ";
}
}
print "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment