Aboveyou has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, this is my code : how do i increase the size of the scrollbar/frame window ? how do i clear the text widgets on every new search i run ?
################# #Scroll Bar # ################# my $mwf = $mw->Scrolled( 'Pane', -scrollbars => 'e', -background => 'white', -sticky => 'nwse', )->pack(-padx => 0, -pady => 230 , -expand => 0,-fill => 'both'); ################# #Sub Search # ################# sub copy_entry { $copy_text = $dude->get(); chomp($copy_text); $queryHandle = $dbshop->prepare(" SELECT * FROM Department WHERE ( Ext + = '$copy_text' OR Mobile = '$copy_text' OR [E-Mail] = '$copy_text' +OR [Full Name] = '$copy_text' OR [Direct Number] = '$copy_text' ) "); $queryHandle->execute() or die $DBI::errstr; while (@row = $queryHandle->fetchrow) { $f1 = $mwf->Frame()->pack(-expand => 0,-fill => 'both' ); my %dudes; foreach my $fr($f1){ my $i =0; foreach (1..5){ $dudes{'text'} = $fr->Text( -background => 'white', -foreground => 'black', -height => 1, -width => 21 )->pack(-side=>'left',-expand => 1, -fill => 'both' ); $dudes{'text'}->insert('end', $row[$i]); $i++; } } } $queryHandle->finish(); } MainLoop; MainLoop();

Replies are listed 'Best First'.
Re: A few que
by CountZero (Bishop) on Feb 04, 2009 at 06:34 UTC
    I am not a specialist on GUI design and programming, so I leave that to other Monks to comment upon, but I do work with databases and I find this code strange:
    $queryHandle = $dbshop->prepare(" SELECT * FROM Department WHERE ( Ext + = '$copy_text' OR Mobile = '$copy_text' OR [E-Mail] = '$copy_text' +OR [Full Name] = '$copy_text' OR [Direct Number] = '$copy_text' ) "); $queryHandle->execute() or die $DBI::errstr;
    You really should replace all instances of '$copy_text' with the placeholder ? and leave the quoting up to DBI/DBD. Your code is likely to fail if '$copy_text' contains a single quote somewhere in the string.

    It also protects against SQL code injection. Your quoting is easily circumvented by putting something like

    '); delete from Department;'
    (note all the single quotes!) in '$copy_text'.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: A few que
by slacker (Friar) on Feb 03, 2009 at 18:23 UTC
    Any chance you could post a couple screen shots? Are you including additional modules? Is this a webpage? Perl/TK?
    Also, please see
    How Not To Ask Questions