Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^5: Reading tab/whitespace delimited text file

by BrowserUk (Pope)
on Nov 01, 2012 at 13:08 UTC ( #1001822=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Reading tab/whitespace delimited text file
in thread Reading tab/whitespace delimited text file

Because in order to find the length of each field in this crazy format, it relies on the length of the header field to determine the length of the value fields.

But, (uniquely) in the case of:

CELL LUC325C

The header field is shorter than the value field.

And as that record pair was not a part of the sample you showed when you originally asked this question, the code does not cater for it.

Adding this line to the code above will allow it to handle that part of the data format:

$tmpl =~ s[\d+$][*];

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

RIP Neil Armstrong


Comment on Re^5: Reading tab/whitespace delimited text file
Select or Download Code
Re^6: Reading tab/whitespace delimited text file
by reaper9187 (Scribe) on Nov 02, 2012 at 10:57 UTC
    Thank you soooo much for helping .. i'm a newbie to perl and figuring out everything as i go on ...
    The code works perfectly ..!!!!! However , while this works for a sample data , when i use it parse the actual text file , it behaves weirdly .. This is what i get for the sample data :
    { AWOFFSET => 5, BQOFFSET => 3, BQOFFSETAFR => 3, CAND => "BOTH", CELL => "LUC325C", CELLR => "LUC232A", CS => "NO", DIR => "MUTUAL", HIHYST => 5, KHYST => 3, KOFFSETN => "", KOFFSETP => 0, LHYST => 3, LOFFSETN => "", LOFFSETP => 0, LOHYST => 3, OFFSETN => "", OFFSETP => 0, TRHYST => 2, TROFFSETN => "", TROFFSETP => 0, } Press any key to continue . . .

    And this is what i get when i execute it on a text file :
    { CELL => "LUC325C" } { BOTH => "", LUC325B => "", MUTUAL => "", NO => "" } {} { BQOFFSETAFR => "", HIHYST => 5, LOHYST => "3 0", OFFSETN => "", OFFSETP => 3, } { BOTH => "", LUC116A => "", MUTUAL => "", NO => "" } {} { BQOFFSETAFR => "", HIHYST => 5, LOHYST => "3 0", OFFSETN => "", OFFSETP => 3, } { BOTH => "", LUC204A => "", MUTUAL => "", NO => "" } {} Press any key to continue . . .

    Any idea as to why this behaves differently for the same set of data ?????
      Any idea as to why this behaves differently for the same set of data ?????

      I'll need to see both the exact code you are using and the exact datafile. (I'll /msg you my email id.)


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      RIP Neil Armstrong

        Why does the original code behave differently when i use the while(<FILEHANDLE>) loop as a file handle to read a particular section of code(say between line 2-10) instead of using EOF ..???

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1001822]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2014-07-30 22:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (241 votes), past polls