summaryrefslogtreecommitdiff
path: root/ordval.pl
blob: 4e890f7173a478850fa944d74fbd196e451c3e9f (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/perl
use POSIX;

if ( length(@ARGV) <= 0 ){
    print( "Usage: ".__FILE__." [text]\n" );
    exit( 0 );
}

my @txt_array = split( m//, $ARGV[0] );
if ( length(@txt_array) <= 0 ){
    undef @txt_array;
    print( "Error: No text given\n" );
    exit( 0 );
}

my $arr_len = scalar(@txt_array) - 1;
my $iter_count = 0;

foreach my $arr_item (@txt_array){
    print( ord($arr_item) );
    if ( $iter_count < $arr_len ){
        print( ", " );
    }
    $iter_count++;
}

undef $arr_len;
undef $iter_count;
undef @txt_array;

print( "\n" );

exit( 0 );