use strict; use warnings; my @FieldNames = ( 'One' , 'Two' , 'Three' , 'Four' , 'Five' ) ; my $Foo = join(($_ eq 'One' ? '1' : 'n'), @FieldNames); print("\$Foo\[$Foo\]\n");