in reply to Execute commands in a string

my $sourcepackage = caller; eval "package $sourcepackage; $code"; print "Error in eval: $@" if $@ ne '';
Change the print to be whatever you want to do if there are errors (syntax or runtime) in the string of $code.
------------ :Wq Not an editor command: Wq

Replies are listed 'Best First'.
Re^2: Execute commands in a string
by aplonis (Pilgrim) on Aug 15, 2004 at 20:13 UTC

    That was it! Just the trick, Thanks a heap.