Oh most wise Monks I am a cursed with this problem.

I am creating tags in a Tk::Text widget.
I create tags for phone numbers and tag
for dates. When the user clicks on a
tagged phone number, the phone number gets
added to the 1st column of a table.
When the user clicks on a tagged date a menu
pops up and the user can choose to insert the
the date to the 2nd column or the 3rd column.

I have a sub routine, addToTable, that inserts the
phone numbers and dates into the table.

The problem is that when the user clicks
on a date and chooses 2nd or 3rd I get this message ...

Tk::Error: Not an ARRAY reference at ./tagMenu.pl line 32, <DATA> chun +k 20. [\&main::addToTable,10/10/2002,1,[[(790)555-5555,,],[,,],[,,],[,,],[, +,],[,,],[,,],[,,],[,,],[,,]],{}] (menu invoke)

... It is really strange because I don't get that message
when I click on the phone number !?!?!?!?

I suspect I am doing something wrong.
Please take a look at my code and help me out ... please :)

#!/cygdrive/c/PERL/BIN/perl -w use strict; use Tk; use Tk::ROText; use Tk::Table; use constant COLS => 3; my @TAGS = (); my @tableArray = ( \( 1..COLS ), \( 1..COLS ), \( 1..COLS ), \( 1..COLS ), \( 1..COLS ), \( 1..COLS ), \( 1..COLS ), \( 1..COLS ), \( 1..COLS ), \( 1..COLS ), ); sub addToTable { my $rotext = shift; my $data = shift; my $col = shift; my $tArrRef = shift; my $tWidget = shift; for( my $row=0; $row<10; $row++ ) { my $v = $tArrRef->[$row][$col]; if( length( $v ) == 0 ) { $tArrRef->[$row][$col] = $data; $tWidget->get($row, $col)->configure( -background => 'yell +ow' ); last; } } } ### build GUI my $top = MainWindow->new(); my $rotext = $top->ROText()->pack(); my $table = $top->Scrolled( "Table", -scrollbars => 'e', -columns => COLS, -rows => 3)->pack(); for( my $row=0; $row<10; $row++ ) { for( my $col=0; $col<COLS; $col++ ) { my $widget = $table->Entry( -textvar => \$tableArray[$row][$co +l]); $table->put( $row, $col, $widget ); $tableArray[$row][$col] = ''; } } ### End build GUI ### read data and put in tags my $Lines = 1; while(<DATA>) { my @dates = ( /\d\d\/\d\d\/\d\d\d\d/g ); if( $#dates > -1 ) { foreach my $date ( @dates ) { my $d = quotemeta( $date ); my (@notPh) = split /$d/; for ( my $i=0; $i<$#dates+1; $i++ ) { my $notph = $notPh[$i]; my $rec = {}; my $s = length( $notph ); my $e = length( $date ); $rec->{'start'} = $Lines . "." . $s; $rec->{'end'} = $Lines . "." . ($s + $e); $rec->{'name'} = $d; $rec->{'column'} = 0; my $menu = $rotext->Menu(); $menu->add( 'command', -label => "2nd col", -command => [\&addToTable, $date, 1, \@tableArray, $table +]); $menu->add( 'command', -label => "3rd col", -command => [\&addToTable, $date, 2, \@tableArray, $table +]); $rec->{'script'} = [sub { shift; shift->Post(@_);}, $menu, Ev('X'), Ev +('Y')]; push( @TAGS, $rec ); } } } my @phNumbers = ( /\(\d\d\d\)\d\d\d-\d\d\d\d/g ); if( $#phNumbers > -1 ) { foreach my $ph ( @phNumbers ) { my $p = quotemeta( $ph ); my (@notPh) = split /$p/; for ( my $i=0; $i<$#phNumbers+1; $i++ ) { my $notph = $notPh[$i]; my $rec = {}; my $s = length( $notph ); my $e = length( $ph ); $rec->{'start'} = $Lines . "." . $s; $rec->{'end'} = $Lines . "." . ($s + $e); $rec->{'name'} = $ph; $rec->{'column'} = 0; $rec->{'script'} = [\&addToTable, $ph, 0, \@tableArray +, $table ]; push( @TAGS, $rec ); } } } $rotext->insert( 'end', $_ ); $Lines++; } foreach my $tag( @TAGS ) { print "$tag->{'start'} $tag->{'end'} $tag->{'name'}\n"; $rotext->tagAdd($tag->{'name'}, $tag->{'start'}, $tag->{'end'}); $rotext->tagBind($tag->{'name'}, '<ButtonRelease-1>', $tag->{'scri +pt'} ); $rotext->tagConfigure( $tag->{'name'}, -underline => 1 ); } MainLoop; __DATA__ Blah blah blah balh balh Blah 10/10/2002 blah balh balh Blah blah blah balh balh Blah blah blah balh balh Blah blah blah balh balh Blah blah blah balh balh Blah blah blah balh balh Blah blah ummmm .... blah balh balh stinky dinky 10/12/1999 poo kdsjflkjf saklfjadlkfj sdkfjaslf askfjsalf Blah blah blah balh balh Blah 10/10/2002 blah balh balh Blah blah blah balh balh Blah blah blah balh balh Blah (790)555-5555 blah blah balh balh Blah blah blah balh balh Blah blah blah balh balh Blah blah ummmm .... blah balh balh stinky dinky 10/12/1999 poo kdsjflkjf saklfjadlkfj sdkfjaslf askfjsalf

In reply to Tk::Error that I do not understand. by rbc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.