Menu

#117 bad regex match in sample code

Development Branch
closed-fixed
nobody
5
2002-02-07
2002-02-07
Anonymous
No

Example code in perlfaq4.pod (under <<HERE
documents), should insert newline when '--' is
preceded by space[s], not otherwise. Example
uses \s*, which matches 0 or more spaces,
should be \s+ to match 1 or more spaces.:

($quote = <<' FINIS') =~ s/^\s+//gm;
...we will have peace, when you and all your
works have
perished--and the works of your dark master
to whom you
would deliver us. You are a liar, Saruman, and
a corrupter
of men's hearts. --Theoden in
/usr/src/perl/taint.c
FINIS

# I've added an additional print to show quote
before substitution of ' --'
print $quote . "\n\n";

$quote =~ s/\s*--/\n--/;

print $quote;

produces this:
...we will have peace, when you and all your works
have
perished--and the works of your dark master to
whom you
would deliver us. You are a liar, Saruman, and a
corrupter
of men's hearts. --Theoden in /usr/src/perl/taint.c

...we will have peace, when you and all your works
have
perished
--and the works of your dark master to whom you
would deliver us. You are a liar, Saruman, and a
corrupter
of men's hearts. --Theoden in /usr/src/perl/taint.c

Discussion

  • Don Ellis

    Don Ellis - 2002-02-07

    Logged In: YES
    user_id=451349

    My first time to submit on SourceForge - probably
    should have uploaded a text file to illustrate. I see the
    wrap was pretty much lost on the web page.
    --donls

     
  • Chris Nandor

    Chris Nandor - 2002-02-07
    • status: open --> closed-fixed
     
  • Chris Nandor

    Chris Nandor - 2002-02-07

    Logged In: YES
    user_id=3660

    Thanks for the report. There are a *lot* of perl doc changes
    slated for 5.8.0, and I am not going to apply only some of
    them (except in limited fashion, like perlport, where it's
    necessary) or all of them (too much work) to MacPerl 5.6.1.

    However, I'll make sure the fix goes into perl 5.8.0 (a patch
    has been submitted) so it will be picked up when MacPerl is
    updated to 5.8.0, or if a user updates his local docs to the
    5.8.0 docs.

    Thanks,

    --Chris

     

Log in to post a comment.