#!/usr/bin/perl use strict; use warnings; my $do_me="do_me.pl"; print "(1)Can not read $do_me: $!\n" if $!; foreach my $ending ("\n", '') { print "Create file with",($ending?'':'out')," newline\n"; open(OUT,'>',$do_me) or die "$!"; print "(2)Can not read $do_me: $!\n" if $!; print OUT "q(string)$ending"; close OUT; my $result=do $do_me; print "(3)Can not read $do_me: $!\n" if $!; print "Can not evaluate $do_me: $@\n" if $@; print("$result\n") if defined $result; } print "(4)Can not read $do_me: $!\n" if $!;