#!/usr/bin/perl use strict; use warnings; my @elements = qw( Dies ist ein langer Test langeswort ); my $length = _find_longest(@elements); for my $elem ( @elements ){ print sprintf "%-*s Test\n", $length, $elem; } sub _find_longest{ my $max = 0; for my $e ( @_ ){ my $l = length $e; $max = $l if $l > $max; } return $max; }