in reply to Re^2: Semicolons in webforms
in thread Semicolons in webforms

# strxmltext is a string variable sent by the webserver and will conta +in a semicolon my $stringvariabe = $args{strxmltext};
So, if "$stringvariabe" contains a value like "item1;bottle", and you want to "parse" that, do you mean that you want to split on semicolon to get a "name, value" pair -- like this?
my ( $name, $value ) = split /;/, $stringvariabe;
If you sometimes get three or more strings separated by semicolons, you probably want to assign the result of split to an array:
my @strings = split /;/, $stringvariabe;
Is there something more complicated about the task that you haven't mentioned yet?

Replies are listed 'Best First'.
Re^4: Semicolons in webforms
by dmaranan (Acolyte) on Dec 30, 2007 at 22:14 UTC
    Unfortunately I don't have any control over the client. The problem is that the client is intentionally sending the semicolon as a delimiter (its written in C#). The other issue is the xml string could be a very large xml string with many semicolons. Ideally, I'd be able to simply replace the semicolons with pipes. I'm not really looking to do name value pairs since I need to do further processing of the XML before I handled the data that is delimited with semicolons. Any other advise? Here is another example if this is helpful:
    # this line represents the xml that I would receive from a client. $xmlstring = '<listofitems> <item> <itemid>1234</itemid> <itemname>genericname</itemname> <tablefield>1234;id</tablefield> </item> <item> <itemid>1235></itemid> <itemname>genericname2</itemname> <tablefield>1235;id</tablefield> <tablefield>1;specialtiem</tablefield> </item> </listofitems>';
    In my program I would then parse the xml data into other variables. The problem is that when I attempt to parse the data the semicolon in the tablefield xml tag screws it up. TIA.
      The client may use the semicolon as some kind of internal separator for the XML data, but if the data goes through a HTTP-GET or urlencoded HTTP-POST request, then it must be properly escaped.