diff options
author | stderr64 <stderr64@xservers.dy.fi> | 2024-04-03 00:21:12 +0300 |
---|---|---|
committer | stderr64 <stderr64@xservers.dy.fi> | 2024-04-03 00:21:12 +0300 |
commit | 953dd54bb9af12292351ead972a1e968e20593f9 (patch) | |
tree | caa8ac31397ae45a606ee46bdd2f55e18ff3f237 /ordval.pl | |
download | ordval-master.tar.gz ordval-master.tar.zst |
Diffstat (limited to 'ordval.pl')
-rwxr-xr-x | ordval.pl | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/ordval.pl b/ordval.pl new file mode 100755 index 0000000..4e890f7 --- /dev/null +++ b/ordval.pl @@ -0,0 +1,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 ); |