I think you should study your data first. For example, how are those fields separated? Usually fields are tab-delimited. If this is true with your data, you can split lines with split(/\t/,$line), then the fields will be correctly separated.

On 4/2/15 10:43 AM, Anirban Adhikary wrote:
Hi List

I would like to process a file which has the following structure.

SCGR  SC  DEV            DEV1           NUMDEV  DCP STATE  REASON
   1        0      31           1

SCGR  SC  DEV            DEV1           NUMDEV  DCP STATE  REASON
   2 0 31           1

SCGR  SC  DEV            DEV1           NUMDEV  DCP STATE  REASON
   3 0 31          1

SCGR  SC  DEV            DEV1           NUMDEV  DCP STATE  REASON
   4 0 31          1

Condition is if any field is empty (In this case DEV and DEV1) those has to be replaced by the keyword "NULL". When I am trying to split the line based on whitespace
@elements = split(/\s+/,$line);
in $element[2] entire blank space is coming upto NUMDEV1. so while printing I am not getting the proper output.

How to resolve this problem?

Best Regards
Anirban.


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to