Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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]
[1nickt]: "right now, humans are smarter than in any of those times": define "smart"
[erix]: ah, now you're appraoch downvote-territory ;)
[james28909]: why, what is the point. if you cant see that we are smarter than cavemen then i need to just shutup lol. cavemen didnt propell themselves onto a moon. they stared at it and probably howled

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (14)
As of 2017-12-15 15:03 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (433 votes). Check out past polls.