my $record = $gi->record_by_addr($ip); my @values = map { sprintf $_[0], namify($_[1]), $gi->$_[1] } ( '%s' => 'country', '%s' => 'region', '%s' => 'city', '%s' => 'postal_code', '%.2f' => 'latitude', '%s' => 'longitude', '%s' => 'time_zone', ); my $command = sprintf('say IP: (%s) Hostname: $hostname %s', $ip, $hostname, join(' ', @values), ); Xchat::command($command); sub namify { return join ' ', map { ucfirst } split /_/, shift; }