Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Adding leading zeros to variable data
I'm sure there's a simple solution to my problem but not programing full time I'm not as learned as I'd like to be. I'm working on a script that grabs Airport weather data using Geo::METAR and formats it into a telemetry packet. Now a few of the fields are outputed from Geo::METAR in variable lengths because of changing weather conditions ie. 5 or 20 Mile per hour wind speeds. what I need to do is add leading zeros on so I have three bytes in the field once the script outputs the data ie 005 or 020.
Like I said I'm sure there's an easy way to do it but it escapes me..
My out put packet currently looks like this:
It should look like this:
0 · ·