#!/usr/bin/perl use strict; use warnings; my $body = "Das ist [BILD=margin.gif] und seine Homepage ist [LINK=http://www.martin.de]hier[/LINK]\n"; $body =~ s!\[((\w+).+?)\](?:(.+?)\[/\2\])?!allocate((map{split(/\s+(?=\w+$)/,$_)}split(/\s*=\s*/,$1)),$3?('INHALT',$3):())!gse; sub allocate { my %params = @_; if (exists($params{BILD})) { return &image(\%params); } elsif (exists($params{LINK})) { return &link(\%params); } elsif (exists($params{HEADLINE})) { return &headline(\%params); } else { return "!!Unbekannter Befehl!!" } } sub image { my $args = shift; my $file = $args->{BILD}; chdir("/srv/www/seite/images/") or die "Order nicht gefunden"; if (-e $file) { my $text = $args->{TEXT}; my ($width, $height) = imgsize($file); my $html = "
$text
\n"; return $html; } else { return "Bild nicht gefunden"; } } sub link { my $args = shift; return "{LINK}\">$args->{INHALT}"; }