I have an input of the following format:


09:08:11        XXXXXXXXXXXXX  1.1.1.1          
09:09:03        YYYYYYYY  2.2.2.2         
09:12:37        ZZZZ   3.3.3.3

I am able to extract these individuals fields easily using the regex /(\S+)\s+(\S+)\s+(\S+)\s+/. I named them $time, $name, and $number. My problem is I want to display this so that the $number aligns perfectly. Because the $name can be of any length, what is the best solution for this?

I would like for the output to look like this. Please note that I had to use dots to align the last field since I wasn't able use the spacebar to do this, not sure why. Anyhoo.


09:08:11        XXXXXXXXXXXXX    1.1.1.1          
09:09:03        YYYYYYYY         2.2.2.2         
09:12:37        ZZZZ             3.3.3.3

I thought about putting the $name into an array. And then use a function to find the one with the longest character count. Finally I would pad out the shorter name to match the longest name. Is there a better and more efficient way to do this?

Edit
Report