Daily Programmer - phillydevslack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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