Hi Monks,
Below are the lines in my file. I am reading them into array and storing column values into variables.
ValuesInColumn1 DataColumnB XYZ RowDescription|RowCode|Suppli
+er ID::Region
ValuesInColumn1 DataColumnB XYZ RowDescription|RowCode|Suppli
+er ID::Region
ValuesInColumn1 DataColumnB XYZ RowDescription|RowCode|Suppli
+er ID::Region
ValuesInColumn1 DataColumnB XYZ RowDescription at RowCode
ValuesInColumn1 DataColumnB ABC RowDescription at RowCode
The following will take data from my file, split it.That works if the columns are divided on spaces.
But value for colD is not captured correctly, as string in colD has sapces in between.
If value for $colB = XYZ and $colD contains substring = Region , I need to replace the $colB from XYX to N/A.
foreach my $line (@a) {
my ($colA, $colB, $colC,$colD) = split( /\s+/, $line);
#print "$colD \n";
}
Please help.
-
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.
|