From 953dd54bb9af12292351ead972a1e968e20593f9 Mon Sep 17 00:00:00 2001 From: stderr64 Date: Wed, 3 Apr 2024 00:21:12 +0300 Subject: First commit --- ordval.pl | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 ordval.pl (limited to 'ordval.pl') 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 ); -- cgit v1.2.3-86-g962b