in reply to Remove zero padding from excel mangled Ip addresses
I'm not afraid of regexes, per se, but I frequently have to write code that someone who isn't as decent at them as I am must read and maintain. I don't doubt for a moment that this is do-able with regex, but if it takes me an hour to figure it out, it'll take my teammates two to sort out what it's doing.
In cases like that, I'd use split and sprintf to tidy those numbers up:
Crystal-clear, utterly unambiguous, and it works. It's just my style, and TIMTOWTDI.my (@octets) = split /\./,$input_string; my $output_string = sprintf "%d\.%d\.%d\.%d", $octets[0], $octets[1], $octets[2], $octets[3];
|
|---|