Created
May 10, 2012 03:15
-
-
Save warewolf/2650815 to your computer and use it in GitHub Desktop.
string 2 numbers
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 | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
# my $string = this OR that | |
my $string = shift @ARGV || "hello"; | |
# split(m//,$string) says "split apart each individual character" | |
my (@letters) = split(m//,$string); | |
# uncomment this to see what gets stuck in @letters | |
#print Data::Dumper->Dump([\@letters],[qw($letters)]); | |
my (@numbers) = map { ord($_) } @letters; | |
#print Data::Dumper->Dump([\@numbers],[qw($numbers)]); | |
print "String = $string\n"; | |
# $, is the delimiter between elements of a list that is print()ed. | |
$,=", "; | |
print "Decimal = "; | |
print @numbers; | |
print "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment