Subject: | The visual() method appears not to format POSIX character classes correctly |
With Regexp::Parser 0.20 (the only one on CPAN as of the filing of this
report),
my $regex = Regexp::Parser->new('[[:alpha:]]');
print $regex->visual(), "\n"
produces "[[SCALAR(0x81d280)alphaSCALAR(0x81d280)]]" as output. If I
understand the docs correctly, the output should be "[[:alpha:]]". The
attached patch file is one way to make this happen.
Thank you for your time and attention.
Tom Wyant
Subject: | regexp_parser_objects.patch |
--- lib/Regexp/Parser/Objects.old 2005-05-22 19:39:01.000000000 -0400
+++ lib/Regexp/Parser/Objects.pm 2009-08-03 23:03:28.000000000 -0400
@@ -381,8 +381,11 @@
$self->{data}->type;
}
else {
- join "", $self->{how}, ($self->{neg} ? '^' : ''),
- $self->{type}, $self->{how};
+ my $how = ref $self->{how} eq 'SCALAR' ?
+ ${ $self->{how} } :
+ $self->{how};
+ join "", $how, ($self->{neg} ? '^' : ''),
+ $self->{type}, $how;
}
}
@@ -404,8 +407,11 @@
$self->{data}->visual;
}
else {
- join "", "[", $self->{how}, ($self->{neg} ? '^' : ''),
- $self->{type}, $self->{how}, "]";
+ my $how = ref $self->{how} eq 'SCALAR' ?
+ ${ $self->{how} } :
+ $self->{how};
+ join "", "[", $how, ($self->{neg} ? '^' : ''),
+ $self->{type}, $how, "]";
}
}
}