Hi,
i am reading a text file. and my code looks like below:
open FH, "$INPUT_DIR/$input_file" or die "Couldn't Open File: $!";
while ( <FH> ) {
chomp;
my ($s, $a, $c, $r) = (split / [, \t]/, $_);
the split fucntion process the comma and tab delimited now.
Input file:
process:
clientserver,00001,AIT,SOURCE
clientserver 00001 AIT SOURCE
error:
clientserve|00001|AIT|SOURCE
split should die if it finds the pipe and it should process if it finds comma or tab delimited.
-
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.
|