#!/usr/local/bin/perl use strict; my @continents; my($key, $value); while(){ chomp; my($key, $val)=split /:/; push @continents,$key; } print "@continents\n"; __DATA__ Europe:Germany Europe:France Asia:India Europe:Italy Asia:Japan Asia:Indonesia