Tuesday, May 21, 2013

Perl 에서 hash 의 element 수 구하기

 print scalar(keys %h);  
출처 : How can I find the number of elements in a hash?

Perl 에서 array 복사하기

다음과 같은 대입문은 어레이를 copy 즉 duplicate 함.
      my @a = (1, 2, 3, 4, 5);  
      my @b = @a;  
      for(my $i = 0; $i < scalar(@b); $i = $i + 1)  
      {  
           $b[$i] = $b[$i] + 100;  
      }  
      printArray(\@a);  
      printArray(\@b);  

Monday, May 20, 2013

Perl 에서 array 를 함수의 reference 로 pass 하는 법

 my @a = (10, 20, 30);  
 foo(\@a);  
 sub foo  
 {  
      my $pa = shift;  
      my @a = @$pa;  
      for(my $i = 0; $i < @a; $i = $i + 1)  
      {  
           print "$a[$i]\n";  
      }  
 }  

Sunday, May 19, 2013

Perl 의 array 에서 특정 value 가 element 에 존재하는지 체크하는 법

      my @a = ("A", "B", "C");  
      if(grep(/A/, @a))  
      {  
           print "found it\n";  
      }  
      else  
      {  
           print "Coudn't find it\n";  
      }  
키워드 :exists
참고링크 : How can I check if a Perl array contains a particular value?

Perl 에서 hash 를 sort 하는 법

여기 참조 : Perl 에서 hash 를 print 하는 법
sort 할때의 비교문
integer 로서 비교할 때는 <=> 를 사용하고
string 으로서 비교할 때는 cmp 를 사용한다.

Perl 에서 hash 를 함수의 reference 로 pass 하는 법

여기 참조 : Perl 에서 hash 를 print 하는 법

Perl 에서 hash 를 print 하는 법

 sub printHash_stringKey  
 {  
      my $v = shift;  
      my @keys = sort {$a cmp $b} keys %$v;  
      foreach my $key (@keys)  
      {  
           print "$key: $v->{$key}\n";  
      }  
 }  
 sub printHash_intKey  
 {  
      my $v = shift;  
      my @keys = sort {$a <=> $b} keys %$v;  
      foreach my $key (@keys)  
      {  
           print "$key: $v->{$key}\n";  
      }  
 }  
호출은 printHash(\%hash); 와 같이 하면 됨


Value 로 sort 하는 방법
 sub sortHashByValue  
 {  
      my $hash = shift;  
      my @keys = sort {$hash->{$b} <=> $hash->{$a}} keys %$hash;  
      foreach my $key (@keys)   
      {   
           print "$key: $hash->{$key}\n";  
      }  
 }  

Thursday, May 16, 2013

SlowMp3

Slow Mp3
MP3를 느리게 플레이해주는 어플리케이션
Slow MP3 is a musician's music player. It can slow down, transpose and transcribe songs on the fly. Need to learn a song in a different key from the original? No problem. Want to play a fast solo part over and over again, in half speed? Can do. Cannot identify a chord? Slow MP3 will show the notes to you.
키워드 : 재생

How to open apps from an unidentified developer in OS X Mountain Lion

How to open apps from an unidentified developer in OS X Mountain Lion
By Allyson Kazmucha, Wednesday, Aug 15, 2012 a 11:27 am

Sunday, May 5, 2013

1080p와 1080i

저마다 다른 ‘풀HD’, 기준이 뭐니
블로터닷넷 2013.05.03
‘풀HD’라는 말은 사실 정확한 규격이 아니다. 애초 하드웨어의 한계를 감추기 위한 용어에 가깝다...결론적으로 화면은 1920×1080i와 1280×720p의 해상도를 일컫는다. 이 해상도의 뒤만 따서 ’1080i’와 ’720p’라고 흔히 부른다. 언뜻 보면 1080i가 더 높은 해상도 같지만 이는 한 번에 540줄씩 홀수 짝수로 나눠서 뿌려주는 방식이고 720p는 계속해서 720줄의 화면을 보여주기 때문에 어떤 게 더 화질이 좋다고는 말하기 어렵다... TV 입장에서 보면 소스 포맷은 분명 1080p가 맞다. 그런데 송출하는 영상은 1080i다. 이걸 풀HD로 업스케일링하는 것인데, TV에 전송되는 영상은 분명 풀HD가 맞다. MP3 파일을 CD 포맷으로 바꿔 구운 것과 비슷하다.
키워드 : TV