'Perl'에 해당되는 글 4건

  1. 2016.03.28 perl split
  2. 2016.03.28 perl로 날짜 비교 하기
  3. 2016.01.12 1월 첫째주 정리
  4. 2016.01.08 perl chomp

perl split

카테고리 없음 2016. 3. 28. 19:00

split을 하면 split의 기준이 되는 글자를 제외하고 나머지 부분이 앞 뒤로 배열 형태로 리턴된다. 


형식

my @arr = split /test/ , $str;


Posted by 썬,더 호글
,

1. epoch로 초를 계산해서 30일을 초로 변환해서 뺀 다음에 그 값을 비교 

2. str2+time 을 이용해서 스트링을 epoch로 바꿔서 계산. 스트링을 변환하는 작업을 대신해주는 셈.

3. localtime을 이용해서 epoch로 초단위 계산. 


> 결국 초단위 계산을 통해서 스트링을 날짜 계산하게 된다. 

'배운 것' 카테고리의 다른 글

utf-7 vs utf-8  (0) 2016.04.03
base64 vs base64url safe 차이  (2) 2016.04.03
holder pattern in java  (0) 2016.03.15
[linux command ] which, whereis  (0) 2016.03.04
[linux command] mkdir -p -m  (0) 2016.03.04
Posted by 썬,더 호글
,

1월 첫째주 정리

배운 것 2016. 1. 12. 23:48

## perl split 

```pl

my @word = split /:/, $string;

```


- split 함수가 소괄호 안에 묶여있지 않고, 스플릿 할 대상을 뒤에 방치하는게 특징. 문법이 특이하다. 스플릿을 하고 나면 언제나 그렇듯 배열로 받게 된다. 


##일정한 형식의 python string을 정규표현식 없이 잘라내는 법

string = "0123456789"

print s[0:4]  >> 01234

print string[5:8] >>5678

print string[5:] >>56789

print s[:9] >> 0123456789

print string[-1] >>> 9

print s[-7 : -3] >>> 34567


##python index

str = "12345678"

str2="345"

print str.index(str2) >> 2


인자로 넣은 스트링이 존재하는 첫번째 문자의 위치값이 반환된다. 


##grep -B 20 "test" filename

파일 내에 test라는 글자가 있는 라인으로부터 -Before 20줄을 출력한다. 




'배운 것' 카테고리의 다른 글

command pattern  (0) 2016.01.28
log4j error  (0) 2016.01.26
intellij 에서 maven profile 선택해서 실행하기  (0) 2016.01.19
logback.xml 에서 에러로그 분리  (0) 2016.01.18
perl chomp  (0) 2016.01.08
Posted by 썬,더 호글
,

perl chomp

배운 것 2016. 1. 8. 10:52

perl chomp, chop 함수 (개행문자 삭제)


line에 \n이 붙어있을 경우 삭제해준다.

'배운 것' 카테고리의 다른 글

command pattern  (0) 2016.01.28
log4j error  (0) 2016.01.26
intellij 에서 maven profile 선택해서 실행하기  (0) 2016.01.19
logback.xml 에서 에러로그 분리  (0) 2016.01.18
1월 첫째주 정리  (0) 2016.01.12
Posted by 썬,더 호글
,