#!/usr/bin/perl -w use strict; my $method = shift || 1; my $filename = shift || 'other.pl'; my $sub = shift || 'hello'; if ($method == 1) { print "First method\n"; { local $/; open OTHER, "< $filename" or die "can't open\n"; my $other = ; close OTHER; eval $other . ";$sub"; } } elsif ($method == 2) { print "Second method\n"; scalar eval `cat $filename`; eval $sub; } else { print "Third method\n"; do $filename; eval $sub; } #### #cat other.pl sub hello { print "hello world\n"; } #### # cat other2.pl sub hi { print "hi, world!\n"; } #### $ perl test_runtime.pl 1 other.pl hello #### $ perl test_runtime.pl 2 other2.pl hi $ perl test_runtime.pl 3 other2.pl hi #### _ _ _ _ (_|| | |(_|>< _|