in reply to Re^3: perlmonks downloadable code blocks
in thread perlmonks downloadable code blocks

Well if I use the global "/g" modifier it will replace all of my tags at once and $i will never be incremented.
  • Comment on Re^4: perlmonks downloadable code blocks

Replies are listed 'Best First'.
Re^5: perlmonks downloadable code blocks
by ikegami (Patriarch) on Apr 11, 2008 at 10:23 UTC

    True, unless you get rid of the while entirely. The first paragraph of s/// documentation reads: (Emphasis mine)

    Searches a string for a pattern, and if found, replaces that pattern with the replacement text and returns the number of substitutions made.

    So you get

    my $post_body = ...from db...; my $match = s/.../.../ig;

    By the way, I don't think $match should be singular. $matches is better but not nearly as descriptive as something like $num_blks.