Created
July 16, 2011 01:43
-
-
Save anonymous/1085900 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use warnings; | |
| use strict; | |
| use Data::Dump; | |
| my $str = | |
| q|host dezoito{hardware ethernet 00:0e:a6:7a:7e:79;fixed-address 192.168.120.118;}|; | |
| my @matches = $str =~ | |
| /^host\s(.*) # nome do host | |
| \{ # abre chaves | |
| hardware\sethernet\s # tag obrigatória | |
| # MAC | |
| (([0-9a-fA-F]{2}:){5} # cinco hexadecimais de 16 bits seguidos de : | |
| # ex. "00:" "FF:" etc... | |
| [0-9a-fA-F]{2}) # último hexadecimal sem o : | |
| ; # finalizador do mac | |
| fixed-address\s # tag obrigatória | |
| # IP | |
| ((?:(?:[1-9][0-9]{0,2})\.){3} # três inteiros de 8 bits seguidos de . | |
| # ex. "192." "10." "223." etc... | |
| (?:[1-9][0-9]{0,2})) # último inteiro sem o . | |
| ; # finalizador do IP | |
| \} # fecha chaves | |
| /x; | |
| print Data::Dump::dump(\@matches); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment