#!/usr/bin/perl

use strict;
use warnings;

sub prt($) { print shift; }

sub icao2number {
	my ($icao) = @_;
	my($number,$n,$i);

	$icao=" ".$icao if(length($icao)==3);
	$icao="  ".$icao if(length($icao)==2);
	$icao="   ".$icao if(length($icao)==1);

	for($i=0;$i<length($icao);$i++)
	{
		$n=ord(substr($icao,$i,1));
                $number.=sprintf("%02d",$n);
	}
	return($number);
}

my $icao = 'YGIL';

my $num = icao2number($icao);

prt(" ICAO [$icao] gives number [$num]\n");

$icao = 'ZZZZ';
$num = icao2number($icao);
prt(" ICAO [$icao] gives number [$num]\n");

