I'd like to know how I can run operations like this
$T = 25 C;
@specs = (273.15 K, 23 bar, 2.0 mol/s);
and get them to compile. I'm not picky about what their result is, or how it's implemented. My goal is to let expressions for physical quantities with conventional postfix unit annotations compile to perl expressions for those units.
I think I need to use custom parsing techniques, but I'd prefer to use any existing functionality or parsing modules over just applying regex filters to my raw source.
Parse::Keyword seemed promising, but I can't see whether it can parse postfix operations, and it claims to be deprecated.
Edit: I'd like to avoid source filters if possible because I'd rather not write regexes for Perl's syntactical corner cases (e.g. "25 (J/K)").
The error Perl produces here is telling:
perl -E "25 C"
Bareword found where operator expected at -e line 1, near "25 C"
(Missing operator before C?)
It seems like I need to hook into where Perl detects operators after numeric literals.
Could Devel::Declare add postfix operators? If so, how?