[comp.lang.perl] ' in character class

lws@comm.wang.com (Lyle Seaman) (08/11/90)

Isn't there some way to get a ' into a character class?
I want to to do something like:
/[\w\.\-\']+/   ie, match a string of alphanumerics, periods, hyphens and
apostrophes.

But PERL always complains.  If somebody could explain what that 
sequence above really means, and/or how I can what I want, I'd
be most grateful.

-- 
Lyle                      Wang             lws@comm.wang.com
508 967 2322         Lowell, MA, USA       uunet!comm.wang.com!lws

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (08/12/90)

In article <1990Aug11.001936.16075@comm.wang.com> lws@comm.wang.com (Lyle Seaman) writes:
: Isn't there some way to get a ' into a character class?
: I want to to do something like:
: /[\w\.\-\']+/   ie, match a string of alphanumerics, periods, hyphens and
: apostrophes.
: 
: But PERL always complains.  If somebody could explain what that 
: sequence above really means, and/or how I can what I want, I'd
: be most grateful.

The problem isn't \' but \-.   This is fixed in patchlevel 27.

Larry

lws@comm.wang.com (Lyle Seaman) (08/13/90)

Problem solved.  As one responder pointed out (thanks again Tom),
rearranging the character class [\w\.\-\'] to be [\w\'\.\-] circumvents 
the problem.  This is ostensibly because ' is before . in the ASCII
collating sequence.  Larry, can this be true?  I haven't seen that
documented anywhere, doncha think that's kind of subtle?

Larry Wall said that the problem was due to a bug in the handling of \-
which is fixed in PL 27.  Could that bug be successfully circumvented 
in the fashion described above?

-- 
Lyle                      Wang             lws@comm.wang.com
508 967 2322         Lowell, MA, USA       uunet!comm.wang.com!lws