#!/usr/bin/perl use strict; use warnings; my $string = 'datei.bas'; print right($string,2),"\n", left($string,4); sub right{ my ($string,$nr) = @_; return substr $string, -$nr, $nr; } sub left{ my ($string,$nr) = @_; return substr $string, 0, $nr; }