in reply to RegExp error PLEASE HELP!

Hi harangzsolt33,

As others have pointed out, the first argument to split is a regular expression. So to protect against special characters you could do something like split(quotemeta($PATTERN), $STRING, 2); (see quotemeta).

However, you don't need to parse URLs by hand, there's the URI module:

my @urls = ( "file:///c:/html/testing.html?P1=123&P2=%28%28BLAH+BLAH+BLAH%29%29 +", "http://www.cnn.org/g/ar.shtml?c=123055&s=%28Top+Stories+%29", "http://www.something.com/example/article.php?P1=123&P2=%28%28DATA ++GOES+HERE%29%29%0D%0A#PGTOP", ); use URI; for my $url (@urls) { my $u = URI->new($url); print "$u\n"; my @q = $u->query_form; print "\t\"$_\"\n" for @q; } __END__ file:///c:/html/testing.html?P1=123&P2=%28%28BLAH+BLAH+BLAH%29%29 "P1" "123" "P2" "((BLAH BLAH BLAH))" http://www.cnn.org/g/ar.shtml?c=123055&s=%28Top+Stories+%29 "c" "123055" "s" "(Top Stories )" http://www.something.com/example/article.php?P1=123&P2=%28%28DATA+GOES ++HERE%29%29%0D%0A#PGTOP "P1" "123" "P2" "((DATA GOES HERE)) "

Hope this helps,
-- Hauke D

Replies are listed 'Best First'.
Re^2: RegExp error PLEASE HELP!
by harangzsolt33 (Deacon) on Jul 04, 2016 at 20:04 UTC

    Oh, wow. Thanks!! I didn't know that.

    Ok, I wasn't aware that split() expects a regular expression... That's why. Ugh. :-P

    And sorry, I wasn't shouting. didn't mean to. LOL

    See, one of the reasons why I've come to like the perl language is because you can ask a question and get an answer INSTANTLY even on July 4th when everybody is resting and cooking BBQ outside. And the internet is full of perl documentation. There are thousands and millions and billions of pages of helpful stuff written about Perl. And it's available all for free. You don't get the same help with other languages. :-D

      you can ask a question and get an answer INSTANTLY even on July 4th when everybody is resting and cooking BBQ outside

      You seem to have a very limited view of the world. You know, earth has way more surface than just the tiny 2% of the USA, and there are very different cultures on the remaining surface. In many places of the world, July 4th is just an ordinary (work) day, perhaps too cold and wet for any kind of BBQ.

      And the internet is full of perl documentation. There are thousands and millions and billions of pages of helpful stuff written about Perl. And it's available all for free.

      Most of it, I guess, yes. But often, you get what you paid for. Crappy code written for Perl 4, or ancient versions of Perl 5, by people knowing neither Perl nor how to write reliable software.

      This is not limited to perl, you can find lots of crappy, ancient code for any mainstream language.

      You don't get the same help with other languages. :-D

      Yes, you do, with similar results. At least for mainstream languages. When it comes to really exotic stuff, like MUMPS or embedded languages for niche products (like medical or lab environments), things get harder, and answers get rarer.

      One thing about Perl that really stands out is CPAN. Almost everything you need for your Perl problem, in one place, and in the best case with a comprehensive set of tests for each package you want to install. Of course, not even CPAN is a paradise of perfect code, and you can find crap on CPAN, too. But try to find a library to access databases, to interface with a webserver, or to implement some obscure network protocol for a different language. You need a good search engine and a lot of luck, because people tend to host their libraries at some random place on the web. You may even have to pay for access to the libs, either with personal data or with money.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)