#!/usr/bin/perl use strict; use warnings; print button(type => 'image', name => 'name', value=> 'test', text => 'Hallo'); sub button{ my %args = @_; my $options = ' '; for my $key( qw(type name value) ){ $options .= $key . '="' . $args{$key} . '"' if exists $args{$key}; } my $text = $args{text} || 'defaulttext'; print ""; }