in reply to Re^2: PERL scripts-Yahoo Groups Download-i get an error
in thread PERL scripts-Yahoo Groups Download-i get an error

$cells is unititialized because the "find stuff between these to comments" match is failing.

The pattern's looking for the shortest string it can find between the start and end comments for the content include, throwing away any leading spaces. Here's how it breaks down:

\s+ # one or more spaces - don't capture these ( # start capturing .+? # one or more anythings, shortest match to what follows ) # end capture
Check the text of the page in $content; my guess is that the Groups folks have reformatted their pages, and the comments that this match is looking for have changed.

Replies are listed 'Best First'.
Re^4: PERL scripts-Yahoo Groups Download-i get an error
by Anonymous Monk on Mar 22, 2009 at 21:18 UTC
    So it is copying in $cells every string that is between "( )" from $content?
    $content is full of strings between "( )", links, functions, arguments,etc.
      Sorry - I assumed a little too much about what you know about regular expressions.

      In Perl regular expressions, unescaped parentheses signal that we're going to capture anything that matches the pattern inside the parens. There are no parens expected to be matched in the text we're analyzing; they're just a shorthand for "See this pattern here, between these parens? I want to save the stuff that this part of the pattern matches".

      Here's an example. If we had this:

      my($meta_thing) = ($string =~ /(foo|bar|baz)/;
      we'd be saying, "please look for a 'foo', a 'bar' or a 'baz' string in the variable $string. If you find any of those matches, please save the thing you matched into $meta_thing". The pattern you have in the code you're looking at essentially says "please find an HTML comment that looks like this (don't save that); then skip however many whitespace characters you find (don't save those either); then start capturing every character you see up to the first time you find the other HTML comment (and save those); when you see the second comment, quit capturing, and save all the stuff you captured into /$cells. Don't save the second comment either."

      The code after that is trying to break out table rows and cells from the stuff that was captured. Does that help clear it up a bit more?

      I highly recommend reading perldoc perlre if you have no Perl books. I also recommend getting hold of "Learning Perl" if you want to learn more about this stuff.