Skip to content

Instantly share code, notes, and snippets.

#这个问题解决了:
#Most of the power comes from the implicit smartmatching
#that can sometimes apply. Most of the time, when(EXPR) is
#treated as an implicit smartmatch of $_ , that is, $_ ~~ EXPR .
#(See Smartmatch Operator in perlop for more information on smartmatching.)
#But when EXPR is one of the 10 exceptional cases
#(or things like them) listed below, it is used directly as a boolean.
#1. A user-defined subroutine call or a method invocation.
#其他省略
@terrencehan
terrencehan / gist:4050553
Created November 10, 2012 09:28
check if the machine is big-end or small-end
#include <stdlib.h>
#include <stdio.h>
void
print_in_byte(void *a, int size){
char *byte_ptr = (char *) a;
while (size--) {
printf("%.2x ", *byte_ptr++);
}
printf("\n");
#你在使用这个代码之前先要把输入文件转换成UTF-8的编码
open $in, "<", "a.txt";
while (<$in>) {
chomp;
( $city, $pinyin ) = split;
$city .= "市";
$hash{$city} = $pinyin;
}
#!/usr/bin/env perl
use 5.010;
use strict;
use List::MoreUtils qw(pairwise);
use Text::Extract::Word;
sub foo {
sprintf "%.3d", shift;
}