Two things stand out here:
- $ARGV[2] might contain un-decoded UTF-8 characters in "modern" terminals. File systems with UTF-8 characters behave differently, depending on the platform (Windows/Unix).
- (/$line) looks weird. That needs really special values for $line to produce valid Perl!
An idea is to print the string you're evaling, and of course checking whether eval produced an error in $@:
my $code = qq~modes::~ . $ARGV[2] . qq~::flex(/$line);~;
warn $code;
eval $code;
warn "Eval failed: '$@'" if $@;