Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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"


Comment on Re: Match integer or floating point numbers, then parse triplets
Download Code
Re^2: Match integer or floating point numbers, then parse triplets
by GrandFather (Cardinal) on Sep 15, 2011 at 04:39 UTC

    "The cake is a lie."

    True laziness is hard work

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://925994]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2014-09-17 22:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (100 votes), past polls