in reply to Re: Substr warning
in thread Substr warning

Hi,

I am extracting information from a html-site, which I have stripped of tags, etc. beforehand. In this instance, I am interested in the two words following the string "Rapporteur: ".

There is probably a better way of doing it, but at the moment I am using $' to get the text after the string I searched for and then read in every single character once at a time, add it to my variable until there have been two character that equal " " (thus, I have two words).

I am confused about the substr warning as I am sure, that there are plenty of characters left in the substring.

Hope this makes my dilemma clearer.

Replies are listed 'Best First'.
Re^3: Substr warning
by Jenda (Abbot) on Sep 27, 2004 at 13:45 UTC

    Yes it does. You can (and should) do this by a single regex. Like this:

    if ($html =~ /Rapporteur: (\S+ \S+)/) { $reporters_name = $1; }

    The regexp searches for "Rapporteur:" followed by a single space, then some non-space characters, a single space and again some nonspace chars. And it captures those two groups of nonspace characters.

    Jenda
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
       -- Rick Osborne