Hi there, i wonder if somebody could help
I have a file that i want to split out into a hash, but the delimiter is either a space or a comma but the last column needs to be able to include spaces ..
so for example my file
/opt/accounts 80,90,60,70 Accounts Team
/opt/finance 70,45,90,89 Finance Team
which I split out using into a hash by doing the following
open (IN, "/var/opt/file.cfg");
while (<IN>) {
chomp();
my ( $filesystem,$warning,$minor,$major,$critical,$team ) = split(/[ ,]/);
$hash->{$counter} = {
counter => $counter,
filesystem => $filesystem,
warning => $warning,
major => $major,
minor => $minor,
critical => $critical,
team => $team
};
$counter++;
}
but the problem is, because I have split() using commas and spaces, when it comes to the last value I want to capture, its pulling "Accounts" into the hash instead of "Accounts Team".
unfortunately I am unable to change the source file, but does anyone know how I can split using spaces and commas except for the last column ? (which incedentally will always be the 6th and last value in the file)
any help on this would be greatly appreciated