I have a long .csv file that consists of device information. Each line is a unique device with its own info listed as such: MACaddr,,,,Date,Date,,"b,n",,blahblahblah. It's irrelevant what that all stands for.
What I need to do is take in the file and then write to a new file with all lines/devices that have the same Vendor MAC (i.e. the first 3 octets of the MAC Address) grouped together. I can easily take in each line and grab the Vendor MAC with a regex but then I am stuck.
All I have is:
#!usr/bin/perl
use strict;
use warnings;
open IN, "wirelessClients.csv" or die "Couldn't open file\n$!";
open OUT, ">sortedClients.csv" or die "Couldn't open out file\n$!";
my @clients = <IN>;
foreach my $client (@clients)
{
if($client =~ /^(\w+:\w+:\w+)/)
{
print OUT "$1,$client\n\n";
}
}
I have no idea how to go about sorting the information.
Any help and/or guidance would be greatly appreciated!