Thank you fellow monks. This week I decided to learn perl. I am some data in a text as per example below.

{"temp":70.00,"tmode":2,"fmode":0,"override":0,"hold":0,"t_cool":70.00 +,"tstate":0,"fstate":0,"time":"day":3,"hour":23,"minute":29},"t_type_ +post":0}
All of the data is in one line and repeats at time intervals throughout the day. I have been trying to understand a simple way for me to learn perl and use the above an a beginners way to learn to extraction of data. My simple program I have creatd below.

#! /usr/bin/perl open (FILE, '/home/julian/tstatcollect'); while (<FILE>) { chomp; ($temp, $tmode, $fmode, $override,) = split (","); #my %newval = split (/[:]/, $temp); print "Temperature: $temp\n"; print "Tmode: $tmode\n"; print "Fmode: $fmode\n"; print "Override: $override\n"; print "________\n"; } close (FILE); exit;
_______________________________________________ output shows
Temperature: {"temp":70.00 Tmode: "tmode":2 Fmode: "fmode":0 Override: "override":0
I understand that what it is doing is parsing out the data between each ,. What I was hoping to do is figure out how I can use split to parse the data between each " " and each : and ,. Is split the right way to go about this. Hopefully there is a simple way? Again, remember I just started last week so as simple as possible would be best. Thanks, Julian.


In reply to Proper use of split by th3j4ckl3

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.