Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: grabbing dmidecode memory data - there's got to be a better way

by Tommy (Chaplain)
on Dec 28, 2012 at 19:31 UTC ( #1010737=note: print w/replies, xml ) Need Help??


in reply to Re: grabbing dmidecode memory data - there's got to be a better way
in thread grabbing dmidecode memory data - there's got to be a better way

Yes, that's cool! First slurp, then split on paragraph chunks, and finally simply match against keywords in the block. That's nice. Could you have not done that without the zero-width positive look-behind? Seems like that would be the best way, but I still wonder...

--
Tommy
$ perl -MMIME::Base64 -e 'print decode_base64 "YWNlQHRvbW15YnV0bGVyLm1lCg=="'
  • Comment on Re^2: grabbing dmidecode memory data - there's got to be a better way
  • Download Code

Replies are listed 'Best First'.
Re^3: grabbing dmidecode memory data - there's got to be a better way
by kennethk (Abbot) on Dec 28, 2012 at 19:41 UTC
    You could simplify the split to \n\n+ or something similar, but then you need to modify something else to keep the records newline separated. I'm willing to go to pretty extreme lengths to keep print if /RAM socket/ && !/Not Installed/ clean just because of personal taste. TIMTOWTDI.

    dmidecode | perl -e 'undef $/;/RAM socket/ && !/Not Installed/ && s/$/\n\n/ && print for split /\n\n+/, <>'


    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      That's another good example. Less clear than your first, but still much less ugly than my original line-by-line cherry picker.

      --
      Tommy
      $ perl -MMIME::Base64 -e 'print decode_base64 "YWNlQHRvbW15YnV0bGVyLm1lCg=="'

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1010737]
help
Chatterbox?
talexb admires the shimmering pool after an enjoyable hour-long All Hands meeting spent listening with one ear and reading Perlmonks with the other .. ear.
[talexb]: Used all my votes during that meeting .. been a while since I've done that. Now, back to work. Good localtime, monks!
[Corion]: talexb: You enjoyed the All Hands meeting in the pool?!
[Corion]: I understand "surfing" in the pool ;)
[talexb]: Corion I admired the pool .. I wasn't .. soaking in it. ;)
[talexb]: Plus, I've been awy from PM for about three weeks .. needed a bit of catch-up time.

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2017-07-20 15:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (304 votes). Check out past polls.