#!/usr/bin/perl use strict; use warnings; my $test = sub { print "ja, klappt!\n"; }; $test->(); open (my $FH,'>','test.pl'); print $FH $test; system('perl test.pl');