2007년 4월 5일 목요일
Date::Simple
# Difference in days between two dates:
$diff = date('2001-08-27') - date('1977-10-05');
# Offset $n days from now:
$date = today() + $n;
print "$date\n"; # uses ISO 8601 format (YYYY-MM-DD)
use Date::Simple ();
my $date = Date::Simple->new('1972-01-17');
my $year = $date->year;
my $month = $date->month;
my $day = $date->day;
use Date::Simple (':all');
my $date2 = ymd($year, $month, $day);
my $date3 = d8('19871218');
my $today = today();
my $tomorrow = $today + 1;
if ($tomorrow->year != $today->year) {
print "Today is New Year's Eve!\n";
}
if ($today > $tomorrow) {
die "warp in space-time continuum";
}
print "Today is ";
print(('Sun','Mon','Tues','Wednes','Thurs','Fri','Satur')
[$today->day_of_week]);
print "day.\n";
# you can also do this:
($date cmp "2001-07-01")
# and this
($date <=> [2001, 7, 1])
#############
format
############
my $change_date = $date->format("%d %b %y");
my $iso_date1 = $date->format("%Y-%m-%d");
my $iso_date2 = $date->format;
알베르 카뮈 - 시지프 신화
그외의 문제는 먼저 살것인지 죽을것인지가 해결된 이후에 고민할 일이다.
나로 하여금 자살이라는것에 대해 새로운 시각을 갖게 해준 책이다.
신들의 저주를 받아 시즈프산으로 커다란 바위를 밀고 올라가는 벌을 받은 인간..
[perl]Spread::ExcelWrite에서 한글 사용
일케 쉬운걸 왜..왜..왜 찾을 수가 없었을까?
#!/usr/bin/perl -w
use strict;
use Spreadsheet::WriteExcel;
use Unicode::Map;
# simple.xls라는 worksheet를 만든다.
my $workbook = Spreadsheet::WriteExcel->new("simple.xls");
my $worksheet = $workbook->add_worksheet();
# 한글을 unicode로 만들어서 write_unicode를 사용해서 worksheet에 기록
my $map = Unicode::Map->new("EUC-KR");
my $utf16 = $map->to_unicode("이것은 한글 테스트 입니다.");
$worksheet->write_unicode(6, 0, $utf16); # TeX revision no.?
excel파일로 저장하기
# Create a new Excel workbook
my $workbook = Spreadsheet::WriteExcel->new("perl.xls");
# Add a worksheet
$worksheet = $workbook->add_worksheet();
# Add and define a format
$format = $workbook->add_format(); # Add a format
$format->set_bold();
$format->set_color('red');
$format->set_align('center');
# Write a formatted and unformatted string, row and column notation.
$col = $row = 0;
$worksheet->write($row, $col, "Hi Excel!", $format);
$worksheet->write(1, $col, "Hi Excel!");
# Write a number and a formula using A1 notation
$worksheet->write('A3', 1.2345);
$worksheet->write('A4', '=SIN(PI()/4)');
perl isNumeric 루틴 샘플
## Sub Name: IsNumeric.
## Description: This sub validates the input to check to see if
##the input is a Numeric value
## Example: 100, 1,000, and 14.00 are valid inputs.
##################################################################
sub IsNumeric {
my $InputString = shift;
if ($InputString !~ /^[0-9|.|,]*$/) {
return 0;
}
else {
return 1;
}
}
2007년 4월 4일 수요일
html의 확장자를 xls로 만들어 내릴 경우
mso format 에 대해서
date: 2007.4.4 15:16 - jk.
확장자를 xls로 만들어서 html로 data를 내릴 경우
<html xmlns:x="urn:schemas-microsoft-com:office:excel">
<head>
<xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>Sheet1</x:Name>
<x:WorksheetOptions>
<x:Selected/>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml>
</head>
<body>
## Misc
# Add a formula to a cell : <td x:num x:fmla="=B2+1"></td>
# Define a cell as Text : <td style='mso-number-format:"\@"'>00123</td>
# Indent a row 2 columns : <td colspan=2 style='mso-ignore:colspan'></td>
# perl sample
#!/usr/bin/perl
use strict;
use warnings;
sub add_xl_header {
return<<EOT;
<html xmlns:x="urn:schemas-microsoft-com:office:excel">
<head>
<xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>Sheet1</x:Name>
<x:WorksheetOptions>
<x:Selected/>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml>
</head>
<body>
EOT
}
sub add_xl_table {
defined(my $array_ref = shift) || return;
my ($use_row_headers, $use_col_headers) = @_;
my $table;
my $max_width = 0;
if ($use_row_headers) {
my $row = shift @$array_ref;
$table .= "<tr>\n";
$table .= "<th>$_</th>\n" for @$row;
$table .= "</tr>\n";
}
for my $row (@$array_ref) {
$max_width = @$row if @$row > $max_width;
$table .= "<tr>\n";
$$row[0] = '<b>' . $$row[0] if $use_col_headers;
$table .= "<td>$_</td>\n" for @$row;
$table .= "</tr>\n";
}
$table = "<table>\n<col span=$max_width style='width:48pt'>\n$tabl
+e</table>\n";
$table;
}
sub add_xl_separator {
my $sep_rows = shift || 1;
return "<table><tr style='mso-xlrowspan:$sep_rows'></tr></table>\n
+";
}
sub add_xl_trailer {
return "</body>\n</html>\n";
}
## Misc
# Add a formula to a cell : <td x:num x:fmla="=B2+1"></td>
# Define a cell as Text : <td style='mso-number-format:"\@"'>00123</
+td>
# Indent a row 2 columns : <td colspan=2 style='mso-ignore:colspan'><
+/td>
my @test_array1 = ( [2, 3, 5] , [7, 11, 13] , [17, 19, 23] );
my @test_array2 = ( ['', 'Height', 'Siblings'], ['Joe', 77, 1], ['Fran
+k', 70, 4] );
print add_xl_header;
print add_xl_table \@test_array1;
print add_xl_separator 3;
print add_xl_table (\@test_array2, 1, 1);
print add_xl_trailer;
공지영 - 우리들의 행복한 시간
행복한 시간이라..제목을 어쩌면 이렇게 잘 지었을까?
우리는 모두 사형집행을 받고 살아가는 존재라는걸 왜 알지 못했을까?
사형수들은 손목과 발목에 커다란 수갑을 항상 차고 있다.
그들이 지은 죄에 비하면 그것은 작은 형벌이라고 생각하는 사람도 있겠지만.
시간이 흐를수록 사형수들은 초월자가 되어간다...세상의 모든것을 버렸기 때문이다.
자신을 위한것은 더이상 그들에겐 의미가 없다.
자신이 해한 사람의 가족들에게 참회의 눈물을 흘린다, 저번에 본 해바라기란 영화가 생각났다. 자신의 아들을 살해한 사형수를 아들로 받아들인 어머니, 그를 사랑하게 된 여동생.
인간에게 용서란 말을 뺀다면 무엇이 남을까??....이젠 살고 싶다..