in reply to Google Translator -> wxPerl frontend

my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_ +; $parent = undef unless defined $parent; $id = -1 unless defined $id; $title = "" unless defined $title; $pos = wxDefaultPosition unless defined $pos; $size = wxDefaultSize unless defined $size; $name = "" unless defined $name;

Perl now has the // operator which would simplify that to:

my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_ +; $parent //= undef; $id //= -1; $title //= ""; $pos //= wxDefaultPosition; $size //= wxDefaultSize; $name //= "";

Although I don't see much point in assigning undef to a variable that already contains undef?

Replies are listed 'Best First'.
Re^2: Google Translator -> wxPerl frontend
by Swalif (Scribe) on Oct 03, 2010 at 18:13 UTC
    This code is wxGlade generated .. Thanks a lot for pointing the // operator great notice..
      fixed the size of the frame by removing Min & Max buttons.. new code:
      $style = wxCAPTION|wxCLOSE_BOX|wxFRAME_NO_TASKBAR|wxCLIP_CHILDREN unless defined $style;
        Interesting enough upon testing the code on windows the first critical point disappeared and the application responses efficiently to requests; I was really impressed this seems to imply that the issue is ubuntu specific, did you notice that some applications like emesene quickly go to unresponsive mode and come back after few seconds?...
        Also sortCombo working great in windows and the options are sorted alphabetically so this one also may be an ubuntu specific..
        however windows wX raised unicode issues.. like the opposite of tk where it works pretty well on windows but on linux no luck with utf8ing the text ;) thanks
Re^2: Google Translator -> wxPerl frontend
by Anonymous Monk on Oct 04, 2010 at 12:06 UTC
      Since only Lingua::Translate->new( src => $tag_1, dest => $tag_2 ) needs connection... how about:
      my ($message, $trans); my $tag_1 = getTag($self->{origin}->GetValue()); my $tag_2 = getTag($self->{destination}->GetValue()); eval { $object = Lingua::Translate->new( src => $tag_1, dest => $tag_2 ) + or die "Cannot Create an instance"; $message = $self->{origin_text}->GetValue(); $trans = $object->translate($message); }; if ($@){$self->{translated_text}->SetValue("An Error occured : $@ + \n Perhaps your not online."); } else{ $self->{translated_text}->SetValue($trans); }