develooper Front page | perl.perl6.internals | Postings from April 2008

Re: [perl #53270] [TODO] Rename/refactor _handle_mswin32()

Thread Previous | Thread Next
From:
Mark Glines
Date:
April 24, 2008 21:54
Subject:
Re: [perl #53270] [TODO] Rename/refactor _handle_mswin32()
On Thu, 24 Apr 2008 20:48:34 -0700
Geoffrey Broadwell <geoff@broadwell.org> wrote:

> Also, the implementation of C<_add_to_libs> is a little wordy.  How's
> this?
> 
>  sub _add_to_libs {
>      my ($self, $args) = @_;
>      croak "_add_to_libs() takes hashref" unless ref($args) eq 'HASH';
> 
>      my $os       = $args->{osname};
>      my $cc       = $args->{cc};
>      my $platform = $os =~ /mswin32/i && $cc =~ /^gcc/i ? 'win32_gcc'   :
>                     $os =~ /mswin32/i                   ? 'win32_other' :
>                     $os =~ /darwin/i                    ? 'darwin'      :
>                                                         ? 'default'     ;
> 
>      my $libs     = $args->{$platform} || $args->{default};
> 
>      $args->{conf}->data->add(' ', libs => $libs);
>      return 1;
>  }

Pretty.  Easy to read, easy to maintain.  And +1 for using Carp,
too.

Mark

Thread Previous | Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About