Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Match integer or floating point numbers, then parse triplets

by metaperl (Curate)
on Sep 14, 2011 at 20:04 UTC ( #925994=note: print w/replies, xml ) Need Help??

in reply to Match integer or floating point numbers, then parse triplets

Thank you Regexp::Common -
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 => ... }
subgoal is a piece of cake.

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 (Sage) on Sep 15, 2011 at 04:39 UTC

    "The cake is a lie."

    True laziness is hard work

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://925994]
[Happy-the-monk]: Discipulus: are there any perl monks in Milano?
[Discipulus]: i the moment likely no
[karlgoethebier]: i wonder now it will be with my glasses.
[Discipulus]: Milan Perl Mongers seems frozen at 2009
[Discipulus]: karl you dont shoot with eyes, you shoot with the soul
[jkva]: Reminds me of Guardians of the Galaxy

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2017-10-20 10:04 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (260 votes). Check out past polls.