Teaching newbies to use eval? What a concept... (like playing with knives) -- well, it's sure to be valuable as a learning experience.
The one thing where eval is basically unavoidable is the use of a string variable within the "tr///" operator. It's simple, basic, and has a bunch of obvious uses in "real-life".
(update: forgot to include an example...)
my %charmap = ( a => 'B', c => 'D', ) # ... could come from a config f
+ile
my $old = join '', keys %charmap;
my $new = join '', values %charmap;
while (<>) {
eval "tr{$old}{$new}";
if ( $@ ) {
die "tr{$old}{$new} failed at line $.: $_";
}
print;
}