I'm trying to extract various bits of data off a given line in a log file, and present them on multiple lines with labels. For instance, I want the following line to end up as presented below:
7226 12 184.108.40.206/30 dungis thaxton-19.sa fast0/47 to michael2-1.sa
IP Block: 220.127.116.11/30
More Data: thaxton-19.sa fast0/47 to michael2-1.sa
Every line in the target file is in the same format, so I don't need to worry about the bits of data being in different orders, but I have not yet come up with a good way to get the code concice enough for my tastes.
What I have so far:
$line =~ /[a-z][a-z0-9\-]+/; #Our usernames can contain numbers and hyphens
$data = $';
print "\nUsername: $&\n";
$line = /\d+\.\d+\.\d+\.\d+\/\d+/; #Grep the IP
print "IP Block: $&\n";
$data =~ s/\s+\b//;
print "More Data: $data\n";
Is there any way I can constrict that down? I'm fairly new to perl and am working on making my code not just more logical, but easier to modify and program for the future.
Thanks in advance,