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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.