Thank you fellow monks. This week I decided to learn perl. I am some data in a text as per example below.
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.{"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}
_______________________________________________ output shows#! /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;
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.Temperature: {"temp":70.00 Tmode: "tmode":2 Fmode: "fmode":0 Override: "override":0
In reply to Proper use of split by th3j4ckl3
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |