[Pdx-pm] Hiding Perlish Churlishness from App users

Eric Wilhelm ewilhelm at sbcglobal.net
Fri Feb 4 08:12:56 PST 2005

# The following was supposedly scribed by
# Keith Lofstrom
# on Thursday 03 February 2005 02:18 pm:

>or ( @BOOLEAN_FIELDS ) { $$Options{ $_ } =~ s/(false|off|no)/0/i }
>Are there any other consequences of this kind of change?  There are
>other places that Dirvish is Perlish Churlish that I want to fix
>(loosening up the syntax on some array options, for example), but
>this is the easiest fix to do.

You don't really want to *hide* the perlishness from the users.  IMO, 
you want it to 'just work' for both those that know perl (I think we 
sometimes think a little differently) and those that don't.  
Hopefully, this doesn't require much hiding.


If you only do the above regex, you still have some holes (e.g. syntax 
errors are true.)

($val =~ s/^(f|false|off|no|n|0*)$/0/i) or
($val =~ s/^(t|true|on|yes|y|1)$/1/i) or
die "invalid value $val for option $opt\n";

That anchors the front and back of the string to catch any typo'd 
garbage, and gets 000 or even undef() to work too. (Written as "~" 
when your config files are in YAML format.)

The opinions expressed in this e-mail were randomly generated by 
the computer and do not necessarily reflect the views of its owner.

More information about the Pdx-pm-list mailing list