locale : locale 변수 한방에 보기

locale 관련 함수들을 한방에 보고 싶었는데 그 방법을 몰랐다. 말 그대로 'locale'을 쓰면 된다. -_-

[ernie:~/homes/] ernielocale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_ALL=en_US.UTF-8

by erniechung | 2010/04/01 17:33 | Unix | 트랙백 | 덧글(0)

X일 전/후 날짜 출력

my $aday_in_sec = 60*60*24; # a day in sec
my $adjust = -8;
my $a = time + ($aday_in_sec * $adjust);

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($a);
$year += 1900;
my $real_m = $mon+1;
my $mm = $real_m < 10 ? "0".$real_m : $real_m;
my $dd = $mday < 10 ? "0".$mday : $mday;
print "$year$mm$dd\n";

$adjust 값을 바꿔 넣으면 됨. (현재는 -8일 전의 날짜 출력)

by erniechung | 2010/03/24 16:10 | Perl | 트랙백 | 덧글(0)

Mac용 텍스트 파일을 Unix용으로 변환


tr '\r' '\n' < macfile.txt > unixfile.txt

Here, \r and \n are special escapesequences that tr interprets as Ctrl-m (acarriage return) and Ctrl-j (a line feed), respectively.

출처: http://kb.iu.edu/data/agiz.html

by erniechung | 2009/10/13 08:21 | 트랙백 | 덧글(0)

LANG 값에 따라 달라지는 sort, uniq 결과

$ cat mlb.query
mlb
ネイド

$ export LANG=ko_KR.UTF-8
$ echo $LANG
ko_KR.UTF-8
$ sort mlb.query | uniq -c
      1 mlb
      1 ネイド


$ export LANG=en_US.UTF-8
$ echo $LANG
en_US.UTF-8
$ sort mlb.query | uniq -c
      2 mlb

by erniechung | 2009/08/31 10:42 | Unix | 트랙백 | 덧글(0)

Perl로 url encode/decode


#!/usr/bin/perl

use URI::Escape;

my $string = "Hello world!";
my $encode = uri_escape($string);

print "Original string: $string\n";
print "URL Encoded string: $encode\n";


출처: http://www.perlhowto.com/encode_and_decode_url_strings

Decode의 경우엔 uri_unescape을 사용하면 된다.

by erniechung | 2009/08/21 17:03 | 트랙백 | 덧글(0)

◀ 이전 페이지다음 페이지 ▶