in reply to Convert a number to another number?
And the output is:#!/usr/bin/perl use warnings; use strict; # # hashes are superb for translations # my %translate = ( 1 => 567898, 2 => 543267, 3 => 234565, 4 => 987654 ); my @data = ( 1, 2, 3, 4 ); for my $data (@data) { print $data, " => ", $translate{$data}, "\n"; }
C:\Code>perl translate.pl 1 => 567898 2 => 543267 3 => 234565 4 => 987654
|
|---|