First let me say thank you for the wealth of good information. I have been doing a lot of reading in areas of various parts of perl that have been called out in each of your replies. Terms like JSON, etc. Again, I am new and its a learning process. Using a personal project as a referance point for me makes it a little bit fun. I think the first response on using the map and undef helped me the most for now in understanding how I can carve up my data, but for some reason in my original post I think my example got butchered and I ran into another problem. It looks the editor field on this website does some strange wrapping of the line I am trying to work with. The end of the data in tstatcollect has a subsection that seems to break the original splits.
My working code now looks like{"temp":75.50,"tmode":2,"fmode":0,"override":0,"hold":0,"t_cool":75.00 +,"tstate":0,"fstate":0,"time":{"day":4,"hour":13,"minute":49},"t_type +_p ost":0}
With an output now of#! /usr/bin/perl open (FILE, '/home/julian/tstatcollect'); while (<FILE>) { chomp; (undef,$temp, undef,$tmode, undef,$fmode, undef,$override, undef,$hold +, undef,$tcool, undef,$tstate, undef,$fstate, undef,$time, undef,$day +, undef,$hour, undef,$minute, undef,$t_type_post,) = map split (":"), + split (","), ; print "Temperature: $temp\n"; print "Tmode: $tmode\n"; print "Fmode: $fmode\n"; print "Override: $override\n"; print "Hold: $hold\n"; print "tcool: $tcool\n"; print "tstate: $tstate\n"; print "fstate: $fstate\n"; print "day: $day\n"; print "hour: $hour\n"; print "minute: $minute\n"; print "t_type_post $t_type_post\n"; print "________\n"; } close (FILE); exit;
It seems as though when the regular format changes to something it doesnt expect the continuing parsing of the data goes to trash? My thought being is do I need do break the data into two forms. One with the first portion and another with the date time nested portion? I also liked the statement made earlier about collecting the data regardless of where its at with regards to the delimiter? Interesting. I apprecaite all the help and its giving me a lot of reading and researching to do for this weekend. I know there is a ton of resources and books written on the subject but without a referance point to start it made it hard to know what I was looking for. This gives me more to work with. Not looking for answers to the problem as much as I am looking for places to start learning. Thanks again. JulianTemperature: 75.50 Tmode: 2 Fmode: 0 Override: 0 Hold: 0 tcool: 75.00 tstate: 0 fstate: 0 day: "hour" hour: "minute" minute: "t_type_post" t_type_post "
In reply to Re: Proper use of split
by th3j4ckl3
in thread Proper use of split
by th3j4ckl3
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |