bh_perl has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

This is my data, I want to extract:

INPUT_NAME INPUT_DATA INFO LSB Length : 76 [4c] Version : >04< [04] Record length : 0 [00] Record Type : '1' [01] Efficiency Indicator : '0' Successful Term Type : '0' [00] Unefficiency Cause : 'f' Resource Alloc Ind : 'f' [ff] Term Origin : 'f' Term Indicator : 'f' [ff] Info Teleservice : 33 [21] Required Bearer Service : 255 [ff] Time Stamp 1 : >030720215113< [03 07 20 21 51 13] Country Code : 1 [00 00 01] Time Stamp 2 : >030720215113< [07 20 21 51 13] Input Info : >5341870393005150< [53 41 87 03 93 00 5 +1 50] List Of Invoked Supp Ser : >< List Information : >1960136771453< [91 06 31 76 17 54 f3] Price ID : >502130101789872< [05 12 03 01 71 98 78 + f2] Price Code : >910631420033f9< [91 06 31 42 00 33 f9] Discount Identity : >1960132400000< [91 06 31 42 00 00 f0] FOC Identity : >0085 3217< [05 f2 31 00 85 32 17] extension : >< Required Bearer Capability : >"FREE< <br>Info Recei frm Fixed Supp +: ><

Actually, they are lot of information here and split by new line. And, I have some trouble here to capture some input_data based on the input_name, as example :

Record Type : 1 Country Code : 1 List Information : 1960136771453 Discount Identity : 1960132400000 Price Code : 910631420033f9 Required Bearer Capability : FREE Info Recei frm Fixed Supp : #(Change to FREE)
The INFO colums could be ignore.

But, if the "Required Bearer Capability" or "Info Recei frm Fixed Supp" are blank then change their input data to "FREE". Then, all the input data will be used for the next calculation based on the "Required Bearer Capability" and "Info Recei frm Fixed Supp" items with the next information/data.

Thanks for your attention,

Edit by tye, formatting

Replies are listed 'Best First'.
Re: Read and captured selected input data ?
by JamesNC (Chaplain) on Jul 22, 2003 at 12:30 UTC
    You asked a similar question before and we gave you the answer to this question Can't read files content I am not sure if you read the post, but the regex is all you have to change if you want to "extract". Now, when you say "extract" usually that means that you want to store that data as a variable, or create a structure. But, it really looks like you just want to change some input data and reformat it for output. The easiest way to do that is to read it a line at a time, and do a substitution like so:
    use strict; while(<DATA>){ ~s/></>FREE</ if /Required Bearer Cap/; ~s/></>FREE</ if /Info Recei frm/; ~s/>FREE</>PRICELESS</ if /Perl Monks Help/; print; } __DATA__ LSB Length : 76 [4c] Version : >04< [04] Record length : 0 [00] Record Type : '1' [01] Efficiency Indicator : '0' Successful Term Type : '0' [00] Unefficiency Cause : 'f' Resource Alloc Ind : 'f' [ff] Term Origin : 'f' Term Indicator : 'f' [ff] Info Teleservice : 33 [21] Required Bearer Service : 255 [ff] Time Stamp 1 : >030720215113< [03 07 20 21 51 13] Country Code : 1 [00 00 01] Time Stamp 2 : >030720215113< [07 20 21 51 13] Input Info : >5341870393005150< [53 41 87 03 93 00 5 +1 50] List Of Invoked Supp Ser : >< List Information : >1960136771453< [91 06 31 76 17 54 f3] Price ID : >502130101789872< [05 12 03 01 71 98 78 + f2] Price Code : >910631420033f9< [91 06 31 42 00 33 f9] Discount Identity : >1960132400000< [91 06 31 42 00 00 f0] FOC Identity : >0085 3217< [05 f2 31 00 85 32 17] extension : >< Required Bearer Capability : >< Info Recei frm Fixed Supp : >< Hotdog at the park : >$5.00< Perl Monks Help : >FREE<


    JamesNC
      Yes you are right james....But anyway, thanks for your attention, I'm very happy with you.. ;-) As your info, I have tried before, so many time and so many changes. But I'm failed. I'm failed when the items value is null or like this ><. So, I do not know where my mistake and why it's happened. Then, I made decision to ask Monks again with real info.
A reply falls below the community's threshold of quality. You may see it by logging in.