#!/usr/bin/perl use strict; use warnings; my $data; $data = '00:04:23:a5:ce:6d > ff:ff:ff:ff:ff:ff, ethertype IPv6 (0x86dd), length 66: (hlim 255, next-header: UDP (17), length: 12) ::.61701 > ff02::1:2:.547: [udp sum ok] dhcp solicit (xid=493907)'; if ($data =~ /^ (\S+)\s # i need this one \>\s (\S+),\s # this one as well \S+\sIPv6\s \( \S+ \),\s\S+\s\d+\:\s \( hlim\s\d+,\s next-header:\s\S+\s\(\d+\),\s length:\s\d+ \)\s (\S+)\s # just as this one \>\s (\S+)\s # this one \[udp\ssum\sok\]\sdhcp\ssolicit\s \( \S+\= (\d+) # and the final number \) /x) { print ">$1<\n"; print ">$2<\n"; print ">$3<\n"; print ">$4<\n"; print ">$5<\n"; }