Skip to content

Instantly share code, notes, and snippets.

@warewolf
Created May 10, 2012 03:15
Show Gist options
  • Save warewolf/2650815 to your computer and use it in GitHub Desktop.
Save warewolf/2650815 to your computer and use it in GitHub Desktop.
string 2 numbers
#!/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