Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hokkaido.pm#11

akiym
December 28, 2013

 Hokkaido.pm#11

Cocoa module, perl-5.19

akiym

December 28, 2013
Tweet

More Decks by akiym

Other Decks in Technology

Transcript

  1. 

  2. (JUIVC w .BD,FZCPBSE-&%  $PDPB%JDUJPOBSZ4FSWJDFT Q6OB[V$IBO  $PDPB(VJ5FTU "OZ&WFOU-FBQ.PUJPO 

    "NPO8FC%JTQBUDIFS%7  5FYU1JDP5FNQMBUF  888'$7JEFP%PXOMPBE  (BNFT1JDSPTT 5FYU$IJOFTF/VNFSBMT+"  *SPI
  3. 

  4. CVJMEFS.Z#VJMEFSQN package builder::MyBuilder; use strict; use warnings; use parent qw(Module::Build);

    use File::Copy; ! sub new { my ($self, %args) = @_; $self->SUPER::new( %args, extra_compiler_flags => ['-Wall'], extra_linker_flags => ['-framework', 'Foundation'], ); } GSBNFXPSLͷϦϯΫ
  5. CVJMEFS.Z#VJMEFSQN sub compile_c { my ($self, $file, %args) = @_;

    ! (my $m_file = $file) =~ s/\.c$/.m/; move($file, $m_file) or die $!; ! $self->SUPER::compile_c($m_file, %args); } ! 1;
  6. σʔλͷม׵ # e.g. NSString → SVPV ! SV* sv =

    sv_2mortal(newSV(0)); sv_setpv(sv, [str UTF8String]);
  7. Ͱ

  8. 

  9. IBTITMJDFTZOUBY my %h = ( blonk => 2, foo =>

    3, squink => 5, bar => 8, ); my %subset = %h{qw/foo bar/}; # => (foo => 3, bar => 8)
  10. σʔλߏ଄ my $foo = { bar => { baz =>

    { a => 1, b => 2, c => 3, } } }; !
  11. σʔλߏ଄ my $foo = { bar => { baz =>

    { a => 1, b => 2, c => 3, } } }; ! my @ab = @{$foo->{bar}{baz}}{qw/a b/}; # => [1, 2] ஍ࠈͬΆ͍
  12. σʔλߏ଄ my $foo = { bar => { baz =>

    { a => 1, b => 2, c => 3, } } }; ! my @ab = $foo->{bar}{baz}->@{qw/a b/}; # => [1, 2]
  13. :PV5VCF%BUB"1* $VAR1 = { 'fmt' => '36', 'fmt_list' => [

    '36', '18', '5', '43', '17' ], 'resolution' => '320x240', 'suffix' => 'flv', 'title' => 'HE-MAN HEYEAYEA SONG FOR 10 HOURS', 'user' => undef, 'video_id' => 'eh7lp9umG2I', 'video_url' => ..., 'video_url_map' => { '17' => { 'fmt' => '17', 'resolution' => '176x144', 'suffix' => '3gp', 'url' => ... }, '18' => { 'fmt' => '18', 'resolution' => '320x240',
  14. w QSPUPUZQFBUUSJCVUF w sub foo($$){}ˠsub foo : prototype($$){} w Perl

    5.19.2から $!が decodeされる w http://d.hatena.ne.jp/syohex/ 20131227/1388149250
  15. ͜ͷίʔυ͸ಈ͘ʁ # メモリは十分にあるとする # perl-5.18.1 (64bit) ! my @a; $a[2**31]

    = 1; ! # => Modification of non-creatable array value attempted, subscript -2147483648 ಈ͔ͳ͍
  16. QFSMҎ߱ͳΒ my @a; $a[2**31] = 1; ! # On 64-bit

    platforms, the internal array functions now use 64-bit offsets, allowing Perl arrays to hold more than 2**31 elements, if you have the memory available.
  17. w .PEVMF1MVHHBCMF w 0CKFDU"DDFTTPS w 1PE-B5F9 w 5FSN6* w 5FYU4PVOEFY

    SFNPWFENPEVMFT w "SDIJWF&YUSBDU w #-JOU w $1"/1-64 w 'JMF$IFDL5SFF w -PH.FTTBHF