Let's say I have a configuration file.
Config.csv
Server,Properties
"so-al-1","48989"
"so-al-3","43278"
"so-al-5","12345"
I need to use a perl script to retrieve the server and properties from the file in order to use the varible's values in my script. Also our client server doesn't want us to install any modules.
So how do I read this document in variables without using a module?
open(FILE,"Config.csv");
undef($/); #sucks the entire file in at once
while(<FILE>){
(@words)=split(/\s+/);
}
close FILE;
for (@words){
s/[\,|\.|\!|\?|\:|\;]//g; #removed punctuation
$word{$_}++;
}
for (sort keys %word){
print "$_ occurred $word{$_} times\n";
}
I did try the above but it doesn't put it to a hash that I wanted.
Edited: I copied the code too fast and missed a line.
Edited: I just found out that there's a question like this in StackOverflow already. How can I parse quoted CSV in Perl with a regex?