Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
As you can see, the string "A" matches the regular expression, and the character "A" is being stuffed into the array.use strict; use Data::Dump qw(dump); my @chars = ("A", "H", "\x0A"); my @found; foreach my $c (@chars) { @found = $c =~ /^([A-G])*$/; dump @found; } __END__ "A" () undef
The behaviour is the same on Win32 (Active State v5.8.8 build 819) as well as Solaris (v.5.8.x)
I guess it has something to do with "\x0A" being newline on *nix (and half a newline on Win32).
But still - is this to be considered a bug, or what?
Is it already well known and accepted?
How would you guys code around it?
A bit confunded,
/L
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: I wan't take undef for an answer
by FunkyMonk (Bishop) on Aug 04, 2007 at 11:27 UTC | |
|
Re: I wan't take undef for an answer
by GrandFather (Saint) on Aug 04, 2007 at 11:42 UTC | |
|
Re: I wan't take undef for an answer
by Anonymous Monk on Aug 04, 2007 at 12:11 UTC |