[Israel.pm] perl/tk warnings

Shlomi Bakish shlomi at il.marvell.com
Tue Apr 20 02:21:04 PDT 2004



Offer Kaye wrote:

>>sub add(){
>>    my $file = shift;
>>    unless (Exists($files_nb)){
>>    $files_w  = $mw->Toplevel();
>>      $files_w->geometry("150x150+40+60");
>>    $files_nb = $files_w->Scrolled('NoteBook')
>>    ->pack(
>>    -fill=>'both',
>>    -expand=>'1');
>>
>>    $files_nb->add($file,-label=>$file)
>>    ->pack();
>>    return;
>>    }
>>}
>>
>>    
>>
>
>Note sure, but perhaps the problem is near the end of the add sub - try
>moving the closing curly brace of the "unless" before the last $files_nb
>part, e.g.:
>
>     $files_nb->add($file,-label=>$file)
>     ->pack();
>     return;
>     }
>
>Should become:
>
>     }
>     $files_nb->add($file,-label=>$file)
>     ->pack();
>     return;
>  
>
 >> I tried, it's the same. Did you run the code and get the error ?

>Now for some general comments:
>1. By your own words, you are an inexperienced Perl programmer. I *highly*
>recommened using the "-w" switch and "use strict;" pragma. Your code will be
>a lot cleaner thanks to them and you'll catch many errors.
>
 >> Of course I use -w, I just wanted to show that I get the warning 
even w/o -w.

>2. "local $mw = MainWindow->new;" -- you probably want to use "my" here, not
>"local". See "perldoc -f local" and "perldoc -f my".
>
 >> ack.

>3. You use a lot of empty return statements: "return;". You do realize that
>returns an empty list/undef value, depending on context? If you're not
>planning to EVER use the return value, just drop the statement- the last
>expression evaluated will be returned instead. I doubt you actually expect
>an undef as a return value...
>
 >> ack.

>4. Don't use "unless". Period. Okay, other people may disagree, it's a
>matter of taste, and maybe with the newer usage form it is a little better,
>for example:
>	print "okay!\n" unless not_okay();
>But to me it has always seemed add complication where non is needed. In your
>case, a simple "if (!Exists($files_nb))" would serve much better. At least
>it is clearer to me... :-)
>5. Use indentation. In the add sub, everything inside the "unless" curlies
>should be indented.
>
 >> I realy try to use correct indentation, but I'm sometimes too lazy...
In general I realize my codes are not 'proffesional', I am not a 
programmer, I'm an electrical engineer, I just use scripts to help get 
the work done faster and better,
and because I'm doing it at my 'free' time, I work "quick and dirty" 
style - if it does the job - I'm happy :)
But thanks a lot for your comments, I'll try to behave...

>
>Hope this helps :-)
>--
>Offer Kaye
>_______________________________________________
>Perl mailing list
>Perl at perl.org.il
>http://www.perl.org.il/mailman/listinfo/perl
>
>
>  
>

-- 
Shlomi Bakish
Marvell Semiconductor Israel Ltd
Test Eng.
E-mail  :  shlomi at il.marvell.com
Tel (office) : +972 4 9091620
Fax (office) : +972 4 9091501
Tel (mobile) : +972 53 750859
WWW page : http://www.marvell.com
*****************************
*      CARPE DIEM           *
***************************** 

----------------------------------------------------------------------
The information contained in this e-mail message is confidential. The
information is intended only for the use of the individual or entity
named above. If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, distribution
or copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately by
telephone, or by e-mail and delete the message from your computer.
----------------------------------------------------------------------





More information about the Perl mailing list