I just love using viper mode in emacs to execute perl: .! perl -MPOSIX -pe ' BEGIN{ $np = qr{ \( (?: (?> [^()]+ ) | (??{ $np }) )* \) }x;$funpat = qr/$np/;} s/($funpat)=(.*)$/"$1=$3".eval($1)."$4"/ge'
This command searches for a balanced set of parens (from the camel book) followed by an equal sign followed by any trailing garbage and evaluates the expression inside the balanced parans. so if you type (4*atan(1))=gobblygook and then execute the above VI/Ex command you get: 4*atan(1))=3.14159265358979 Here is my failed attempt to do date arithmetic: (use Date::Calc ( ":all" ); use Date::Manip; my ( $date, $yy, $dd, $mm ); $date = scalar localtime( ( time() - ( 24 * 60 * 60 ) ) ); $date)="" Can someone help me figure out how to use the eval function in my perl one-liner to evaluate date time arithmetic? Thanks,Siegfried