in reply to Re^3: Parsing problem
in thread Parsing problem

Well - the documentation is not explicit on what acceptable delimeters are for this case. I know the quotes work because I tested them before posting. It would be my preference to use / as the pattern delimiter, but I was trying to get close to the OP's style. Anyway, here is why I think the quotes work:

From the SPLIT function doc
The pattern /PATTERN/ may be replaced with an expression to specify patterns that vary at runtime...

If someone has a better explanation, or finds a stronger reason than tradition or performance for using /, please reply.

    ..."I don't know what the facts are but somebody's certainly going to sit down with him and find out what he knows that they may not know, and make sure he knows what they know that he may not know, and that's a good thing. I think it's a very constructive exchange," --Donald Rumsfeld

Replies are listed 'Best First'.
Re^5: Parsing problem
by Mr. Muskrat (Canon) on Dec 11, 2004 at 23:05 UTC

    I know the quotes work because I tested them before posting.

    Really? So did I and it did not work. The "stronger reason" is that most people forget that double qoutes interpolate and the forward slashes do not. See for yourself.

    #!/usr/bin/perl use strict; use warnings; no warnings 'uninitialized'; # prevents a warning on line 8 my $description = "Some descriptive text here^`my_username"; my ($desc, $username) = split("\^`", $description); print "desc: $desc\n"; print "username: $username\n"; ($desc, $username) = split(/\^`/, $description); print "desc: $desc\n"; print "username: $username\n"; ($desc, $username) = split("\\^`", $description); print "desc: $desc\n"; print "username: $username\n"; __DATA__ desc: Some descriptive text here^`my_username username: desc: Some descriptive text here username: my_username desc: Some descriptive text here username: my_username
      OK - I now see what you are saying. Subtle requirement for escaping the "\". I must have missed it when pasting the code, because I do remember seeing it work.

      Thanks for taking the trouble to post the code to make your case.

          ..."I don't know what the facts are but somebody's certainly going to sit down with him and find out what he knows that they may not know, and make sure he knows what they know that he may not know, and that's a good thing. I think it's a very constructive exchange," --Donald Rumsfeld