coding1227 has asked for the wisdom of the Perl Monks concerning the following question:
I’m not sure how to tackle this… I think that using an array would be the way to go, but I’m not sure how to do this so that the matching structure is enforced & the correct substution (when needed) is implemented.For example, if I have the following raw data: Timestamp: 00:55:46 SATID 17 VAL1 49 VAL2 038 SIGNAL 39 SATID 18 S +ATID 17 VAL1 49 VAL2 038 SATID 19 VAL1 69 VAL2 015 SIGNAL NA + SATID 39 SATID 28 VAL1 36 VAL2 073 SIGNAL + 21 The “corrected” data line should be: Timestamp: 00:55:46 SATID 17 VAL1 49 VAL2 038 SIGNAL 39 + SATID 19 VAL1 69 VAL2 015 SIGNAL NA + SATID 39 SATID 28 VAL1 36 VAL2 073 SIGNAL + 21
#!/usr/bin/perl -l use strict; use warnings; my @lines; while(<DATA>) { push (@lines, $_); } print @lines; # see if it worked __DATA__ Timestamp: 00:55:46 SATID 17 VAL1 49 VAL2 038 SIGNAL 39 SATID 18 S +ATID 17 VAL1 49 VAL2 038 SATID 19 VAL1 69 VAL2 015 SIGNAL NA + SATID 39 SATID 28 VAL1 36 VAL2 073 SIGNAL + 21
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Preserving "Valid" Data?
by tybalt89 (Monsignor) on Apr 04, 2017 at 03:24 UTC | |
by coding1227 (Novice) on Apr 04, 2017 at 05:33 UTC | |
by tybalt89 (Monsignor) on Apr 04, 2017 at 08:30 UTC | |
by coding1227 (Novice) on Apr 05, 2017 at 04:34 UTC |