Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: A graphical regular expression tester.

by liverpole (Monsignor)
on Dec 07, 2006 at 16:00 UTC ( #588373=note: print w/replies, xml ) Need Help??


in reply to A graphical regular expression tester.

Hi reasonablekeith,

You should be aware that the following errors occur when matching the regex "a?Cd" against the data "abcdefg" (with no checkbuttons selected):

Warning: Attempt to load 'Tk::Checkbutton::0.000503063201904297' at /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/Tk/Widget.pm line 287 Tk::Widget::AUTOLOAD('Tk::Checkbutton=HASH(0x860c6a8)') called at /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/Tk.p +m line 406 eval {...} called at /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/Tk.pm line 406 Tk::MainLoop() called at x line 126

s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Replies are listed 'Best First'.
Re^2: A graphical regular expression tester.
by reasonablekeith (Deacon) on Dec 07, 2006 at 18:42 UTC
    Weird, your example tested fine until I clicked one of the switches, then got a similar error to you. However, I noticed the error didn't occur when clicking the checkbox for 'g'. The way subroutine call for this event is handled differently, so I swapped the following....
    < $check_switch_i->bind('<Button-1>', \&button_run('now')); < $check_switch_m->bind('<Button-1>', \&button_run('now')); < $check_switch_s->bind('<Button-1>', \&button_run('now')); > $check_switch_i->bind('<Button-1>', sub { button_run('now') }); > $check_switch_m->bind('<Button-1>', sub { button_run('now') }); > $check_switch_s->bind('<Button-1>', sub { button_run('now') });
    ...and the bug has gone. I've no idea why though. Anyone?

    Cheers, Rob

    ---
    my name's not Keith, and I'm not reasonable.
      Hi reasonablekeith,

      Yes, it's because you're not doing what you think you're doing with:

      $check_switch_i->bind('<Button-1>', \&button_run('now'));

      If you run perl -MO=Deparse on that, it'll show you:

      $check_switch_i->bind('<Button-1>', \(&button_run('now')));

      Which means that you're calling bind with a reference to the results of a call to the subroutine button_run.

      What you want, instead (if you're going to use that style of notation), is the anonymous list syntax:

      $check_switch_i->bind('<Button-1>', [ \&button_run, 'now' ]);

      s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://588373]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2022-10-03 15:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (14 votes). Check out past polls.

    Notices?