-Поиск по дневнику

Поиск сообщений в rss_thedaily_wtf

 -Подписка по e-mail

 

 -Постоянные читатели

 -Статистика

Статистика LiveInternet.ru: показано количество хитов и посетителей
Создан: 06.04.2008
Записей:
Комментариев:
Написано: 0


CodeSOD: A Cup of CIDR

Четверг, 03 Марта 2022 г. 09:30 + в цитатник

Marco sends us some code that he wrote, back in the far off days of 2003. He wrote some code to handle network addresses. Unfortunately, it never quite worked. Specifically it could only handle addresses in the /24 subnet.

Now, this was written in Perl, so you know it involves regexes.

@IPstart = split(/\./,$start); @IPend = split(/\./,$end); &Check_Start_and_EndIP; # converts "short" (dotted) IPs to "long" (undotted) IPs $IPstart = (($IPstart[0]*16777216)+($IPstart[1]*65536)+($IPstart[2]*256)+$IPstart[3]); $IPend = (($IPend[0]*16777216)+($IPend[1]*65536)+($IPend[2]*256)+$IPend[3]); if($IPend < $IPstart) { die "Can't scan backwards"; } $CountIp = $IPstart; $EndIp = $IPend+1; while($CountIp ne $EndIp) { @Class = &GetIP($CountIp); push(@targetlist, "$Class[1]\.$Class[2]\.$Class[3]\.$Class[4]"); $CountIp++; }

This, by the way, is Marco's attempt to fix the broken code. As Marco puts it: "I am not a coder. I 'fix' things."

[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!

https://thedailywtf.com/articles/a-cup-of-cidr

Метки:  

 

Добавить комментарий:
Текст комментария: смайлики

Проверка орфографии: (найти ошибки)

Прикрепить картинку:

 Переводить URL в ссылку
 Подписаться на комментарии
 Подписать картинку