#!/usr/bin/perl use strict; use warnings; my %bits = ( 4 => 'string', 1 => 'this', 3 => 'my', 2 => 'is', ); print join ' ', map $bits{ $_ }, 1 .. 4;