#!/usr/bin/perl use strict; use warnings; sub otevri_pro_zapis (*$) { no strict 'refs'; return open shift, ">", shift; } sub vyrob_print_funkci ($*$) { my ($pred, $jmeno, $za) = @_; my $funkce = sub { print $pred, @_, $za }; { no strict 'refs'; *{$jmeno} = $funkce; } } otevri_pro_zapis(SOUBOR, 'a.txt'); otevri_pro_zapis(my $soubor, 'b.txt'); print SOUBOR 'ahoj'; print $soubor 'ahoj'; vyrob_print_funkci '[', hranaty_print, ']'; hranaty_print('ahoj');