#!/usr/bin/perl use Tk; use Tk::NoteBook; my $top = MainWindow->new( ); $top->geometry('300x300'); my $nb = $top->NoteBook()->pack(); add_tab(); $top->Button( -text => "Add Tab", -command => \&add_tab )->pack(); $top->Button( -text => "Delete Tab", -command => \&delete_tab )->pack(); $top->Button( -text => "Delete second Tab", -command => \&delete_1tab )->pack(); MainLoop(); sub delete_tab { $nb->delete($i--) } sub add_tab { $nb->add(++$i, -label => $i )->pack() } sub delete_1tab { # you can also pass in a page variable here if you want my @list = $nb->info('pages'); print "@list\n"; if( grep{ $_ eq 2 } @list) { $nb->delete(2) } }