Thank you very much for all the replies.To be more clear, now i am working on the below line of code to get the output.I am trying to write some if condition here so that SGW
a-i is renamed to SGW
a-i_LOWCASE and SGW
A-I is renamed to SGW
A-I_UPCASE.Sample data is provided below,Earlier i provided the data file with values but here i am providing the basic sketch file which is supposed to be referred
Sample data
sgw sketch sgwpts1 format EMS,SGW1,%date%,%time%,%sgw-vpnname%,%sgw-vp
+nid%,%sgw-servname%,%sgw-servid%
sgw sketch sgwptsh format EMS,SGWh,%date%,%time%,%sgw-vpnname%,%sgw-vp
+nid%,%sgw-servname%,%sgw-servid%
sgw sketch sgwptsi format EMS,SGWi,%date%,%time%,%sgw-vpnname%,%sgw-vp
+nid%,%sgw-servname%,%sgw-servid%
sgw sketch, sgwptsH format, EMS,SGWH,%date%,%time%,%sgw-vpnname%,%sgw-
+vpnid%,%sgw-servname%,%sgw-servid%
sgw sketch sgwptsI format EMS,SGWI,%date%,%time%,%sgw-vpnname%,%sgw-vp
+nid%,%sgw-servname%,%sgw-servid%
Lines of code i am writing
sub load_sketch {
my ($sketch_file) = @_;
my %all_sketches = ();
open(DAT, $sketch_file) || die("Could not open file $sketch_file!"
+);
my @lines = <DAT>;
close(DAT);
foreach (@lines) {
s/[\r\n\s%]+//g;
my @all_columns = split(',', $_);
$all_sketches{ uc($all_columns[1]).'STAT' } = [ @all_columns ]
+; # Output file will have SGWSTAT in its name
}
return %all_sketches;
}
1; # tells perl that the package is ready to run
Please help me in the above code on how to rename or please suggest if there are better ways to handle it here