#!/usr/bin/perl use strict; my $string = 'Das ist Martin: [BILD=martin.gif NAME="asd ass as" NAME2=hallo]'; $string = ~s!\[(.+?)\]!parse(map{split(/\s+(?=\w+$)/,$_)}split(/\s*=\s*/,$1))!gse; sub parse { my %params = @_; unless (-e $params{BILD}) { return "File not found\n"; } } print $string;