Good formatting is half the job:
#!/usr/bin/env perl
use strict;
use warnings;
my @char;
while (<DATA>) {
@char = split //;
}
comp( \@char );
my $com = "r0a3m4a4j0";
my @com = split //, $com;
dcomp( \@com );
sub dcomp {
my ($com_ref) = @_;
my @com = @$com_ref;
my $car;
for ( my $aa = 0 ; $aa <= $#com ; $aa++ ) {
if ( $com[$aa] !~ /\D/ ) {
print "$car" x ( $com[$aa] );
}
else {
print "$com[$aa]";
$car = "$com[$aa]";
}
}
print "\n";
}
sub comp {
my ($char_ref) = @_;
my @char = @$char_ref;
my $cnt = "";
for ( my $aa = 0 ; $aa <= $#char ; $aa++ ) {
if ( $char[ $aa + 1 ] ) {
if ( $char[$aa] eq $char[ $aa + 1 ] ) {
$cnt++;
}
elsif ($cnt) {
print "$char[$aa]" . "$cnt";
undef $cnt;
}
else {
print "$char[$aa]";
}
}
}
print "\n";
}
__DATA__
raaaammmmmaaaaaj
Regards, Karl
«The Crux of the Biscuit is the Apostrophe»
Furthermore I consider that Donald Trump must be impeached as soon as possible