rbc has asked for the wisdom of the Perl Monks concerning the following question:
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)
#!/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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk::Error that I do not understand.
by gellyfish (Monsignor) on Feb 17, 2002 at 09:48 UTC | |
by IlyaM (Parson) on Feb 17, 2002 at 10:29 UTC | |
by rbc (Curate) on Feb 17, 2002 at 23:27 UTC | |
|
Re: Tk::Error that I do not understand.
by BeernuT (Pilgrim) on Feb 18, 2002 at 03:03 UTC | |
by rbc (Curate) on Feb 18, 2002 at 17:31 UTC |