in reply to Match integer or floating point numbers, then parse triplets
Thank you Regexp::Common -
The mantra of every experienced web application developer is the same: thou shalt separate business logic from display. Ironically, almost all template engines allow violation of this separation principle, which is the very impetus for HTML template engine development.
subgoal is a piece of cake.use Regexp::Common qw /number/; # GOAL: # have $1 contain everything but the leading "0:" # and the trailing ",$intOrFloat" ... in this case ",4.00" $_ = "0:20,1.00,g,1.00;65,4.00,g,4.00"; /0:(.+),($RE{num}{int}|$RE{num}{real})/ and warn $1; # SUBGOAL: # $1 contains a series of triplets separated by semicolons # Each triplet consists of price,quantity,unit_of_measure # The goal is to create an array of hashrefs with this data: # { price => ..., quantity => ..., unit_of_measure => ... }
The mantra of every experienced web application developer is the same: thou shalt separate business logic from display. Ironically, almost all template engines allow violation of this separation principle, which is the very impetus for HTML template engine development.
-- Terence Parr, "Enforcing Strict Model View Separation in Template Engines"
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Match integer or floating point numbers, then parse triplets
by GrandFather (Saint) on Sep 15, 2011 at 04:39 UTC |
In Section
Seekers of Perl Wisdom