[sf-perl] problem use Regexp::Common, "Can't Regexp::Common::FIRSTKEY"...
Quinn Weaver
quinn at pgexperts.com
Fri Mar 1 11:32:55 PST 2013
On Mar 1, 2013, at 10:55 AM, Quinn Weaver <quinn at pgexperts.com> wrote:
> I don't have a full answer, but the immediate problem you're seeing is that the regex is a tied hash and one of the magic hash methods (FIRSTKEY) is not implemented. Why that bothers the debugger I don't know.
Oh, wait, I think I get it. I bet the debugger's x command is trying to display the tied hash by iterating over its elements, but it can't since FIRSTKEY is not implemented.
Anyway, the most straightforward solution is still the same: read the regex from source.
>
> If you want to read the underlying regular expression, try 'perldoc -l Regexp::Common' (using the same Perl as your program uses, of course), then chop the .pm off the result and look in that directory for time.pm or american.pm.
>
> Be warned: this may not help. Some regexes in Regexp::Common (e.g., profanity.pm) are so optimized that they look more like a series of letters and |'s than a regex you or I would write. If you find the Common regex unreadable, you might be better off writing your own after all.
>
> Good luck! Hope that helps a little.
>
> Regards,
>
> --
> Quinn Weaver
> PostgreSQL Experts, Inc. http://pgexperts.com/
> 1-888-743-9778 (my extension: 510)
> Sent from my phone; pardon my brevity.
>
> On Mar 1, 2013, at 7:39 AM, George Hartzell <hartzell at alerce.com> wrote:
>
>>
>> I'm trying to be a good boy and reuse regular expressions from the
>> Regexp::Common world (ultimately $RE{time}{american}). I have things
>> working, but as I was playing around in the debugger I discovered
>> something "funny".
>>
>> It seems that any time I try to touch %RE I get an error, sometimes
>> things Go Badly enough that I end up back at my shell prompt.
>>
>> It blows up with pretty much the same message in 5.14.2, 5.14.3 and
>> 5.16.2 on a current Mac OS X system.
>>
>> (alacrity)[17:26:03]~>>perl -d -e ''
>>
>> Loading DB routines from perl5db.pl version 1.33
>> Editor support available.
>>
>> Enter h or `h h' for help, or `man perldebug' for more help.
>>
>> Debugged program terminated. Use q to quit or R to restart,
>> use o inhibit_exit to avoid stopping after program termination,
>> h q, h R or h o to get additional info.
>> DB<1> use strict
>>
>> DB<2> use warnings
>>
>> DB<3> use Regexp::Common qw(number)
>>
>> DB<4> x $RE{num}{int}
>> 0 Regexp::Common=HASH(0x7fad2c02d828)
>> Can't Regexp::Common::FIRSTKEY at /Users/hartzell/perl5/perlbrew/perls/perl-5.14.3/lib/5.14.3/dumpvar.pl line 205
>> END failed--call queue aborted.
>> at -e line 0
>>
>> This doesn't seem to keep my code from working but it smells funny....
>>
>> Can anyone shed any light on what's going on?
>>
>> g.
>> _______________________________________________
>> SanFrancisco-pm mailing list
>> SanFrancisco-pm at pm.org
>> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm
> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm
More information about the SanFrancisco-pm
mailing list