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

Hi there dear Monks, I'll start explaining my situation before I ask the question. I have to write an application that sends some data to a module over tcp/ip which contains information for this module. This data itself is a record of information formed like :
[from][to][typea][typeb][message]
Note that all these fields can get big (up to 10 MB per field). So
[script1.pl-> Makes ItemData from some fields and puts it as rawdata in a database ] ---> DBI ---> <--- DBI <--- [script2.pl-> reads ItemData from a database sends this data over a socket which is connected with script2 script1.pl knows nothing about the structure of ItemData and also doesn want to know. ] --> TCP/IP ---> <-- TCP/IP <--- [script3.pl recives ItemData and knows how ItemData is formed script3.pl will get all the fields in ItemData and will use this to talk to hardware with it .. (for example a FAX modem or an SMS machine or whatever .. not importand yet) ]
Ehm.. intro is getting to big :) so the Question : What to do with "ItemData" ? (mainly at script3.pl of course. generating it isn difficult) This is my test.pl, maybe you Monks know a better way to deal with my "ItemData" problem ?
$Ione = "Item|One"; $Ione =~ s/\|/\&verti\&kaal\&stre\&epke\;/g; $ItemData = "$Ione|Ite\@m tw\%o|It\"em Th\$ree|Item \\our|Item \'five| +Item \/six"; # # Should be split up in : # Item|One # Ite@m tw%o # It"em Th$ree # Item F\our # Item 'five # Item /six # print $ItemData."\n\n\n"; @words = split(/\|/, "$ItemData"); for (@words) { s/\&verti\&kaal\&stre\&epke\;/\|/g; print $_."\n"; }

Replies are listed 'Best First'.
Re: splitting Any data on a delimiter an putting it back togetter
by CubicSpline (Friar) on Sep 27, 2001 at 21:32 UTC
    Let me ask some common questions here to see if we might be able to help you out:

    • Can you point out the exact place that is giving you the problem?
    • Can you narrow down your problem to the simplest/shortest description for us? Where is the question?
    • Can you provide a short example that is more clear about the acutal work that needs to get done? Psuedocode is fine or well thought-out sentences describing what should happen.
    The monks would certainly like to help, but more concise description of the problem is required.
      Dear PerlMonk replying me :
      • My problem is the storage of a record in one datatype which I can send to another application using TCP/IP. My record can contain binary fields of each max. 20 MB. The other applicatio must be abel to reconstruct the record or at least extract the fields from it. That other application is running on a different computer and the transfer of the data will be by using sockets / tcp/ip.
      • See point one
      • 3) The example was attached to the question below :)