in reply to Parsing email, inserting into database and creating an aggregation report.

Can you post the solution you have tried ? You did have a go didn't you ? Did you have problems with split or with your while loop ?

I think I can see where your problem with split is comming from, perhaps you should use unpack or substr as it looks like fixed width columns

Cheers,
R.

  • Comment on Re: Parsing email and returning the key/values in two hashes

Replies are listed 'Best First'.
Re^2: Parsing email and returning the key/values in two hashes
by Alligator (Novice) on Dec 22, 2004 at 05:47 UTC
    Hi,
    I indeed used 'split' operator, but didn't know how to pack each column value.

      Hi 'gator,

      If you have a line that is fixed width columns you can unpack it based on the widths quite easily. This gets around all the probs of split and fields that can contain a variable amount of whitespace (I suspect your category field easily could)

      # it goes a little like this while (<DATA>) { my ($Name, $Host, $Port, $Rest)=unpack('A15A10A10A*', $_); # now do what you will with them }

      the A tells it to unpack ASCII, the numbers are the number of characters in each column, the A* just grabs the rest 'cos I was too lazy to count all your column widths

      Festive Cheers,
      R.