2011年12月15日星期四

Re: [PerlChina] Fwd: Net::Evernote

Good idea!  As you mentioned Evernote's API, could you please introduce some functions of the API? Thax

Regards
Thinkhy

在 2011年12月15日 下午12:02,Ken Peng <shorttag@gmail.com>写道:
---------- Forwarded message ----------
From: Ken Peng <shorttag@gmail.com>
Date: 2011/12/15
Subject: Net::Evernote
To: module-authors@perl.org


Hi,

I just created a project on CPAN Net::Evernote, it's the most original
0.01 version.

http://search.cpan.org/~yhpeng/Net-Evernote-0.01/lib/Net/Evernote.pm

Evernote's API is a big collection of functions, I don't have that
much time to implement all of them.

If you anybody has the interest with this project, please let me know,
we could co-work with it.

Thanks.

Ken.

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。


--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

Re: [PerlChina] 2011 CN Perl Advent Day 14: CSV & XLS

from the name, it is: Create a new file in the Excel 2007+ XLSX format.

Thanks.

2011/12/15 Michael Zeng <galaxy2004@gmail.com>
use Excel::Writer::XLSX
是不是支持 xls 2007 格式的
 
 

 
2011/12/14 Fayland Lam <fayland@gmail.com>
http://perlchina.github.com/advent.perlchina.org/2011/CSV_XLS.html 

=for advent_year 2011

=for advent_day 14

=for advent_title CSV & XLS

=for advent_author Fayland Lam

Well, 很多人都喜欢用 Excel or OpenOffice Calc 来打开表格文件。所以您的上司,客户或者朋友,会让你输出 csv 或者 xls 给他们。

有些人喜欢直接用 print join(', ', map { '"' . $_ . '"' } @outs) 来输出成 CSV, 但是这是极度不好的行为,因为 outs 里可能有 " 也可能有 ,

所以个人建议,不管是解析 CSV 或者构造 CSV, 都应该使用标准的 CPAN 模块。如 M<Text::CSV_XS>

=begin code

use Data::Dumper;
use Text::CSV_XS;
my $csv = Text::CSV_XS->new ({ binary => 1 }) or
    die "Cannot use CSV: " . Text::CSV_XS->error_diag();

# read
open(my $fh, "<:encoding(utf8)", "test.csv") or die "test.csv: $!";
while (my $row = $csv->getline($fh)) {
    print Dumper(\$row);
}
$csv->eof or $csv->error_diag();
close($fh);

# read from string
my $line = "myid,filename,size as 9mb";
unless ($csv->parse($line)) {
    die "Failed to parse $line: " . $csv->error_diag() . "\n";
}
my @field = $csv->fields;
print Dumper(\@field);

# print out to file
$csv->print($fh, ['myid', 'filename', 'size as 9mb']); print $fh "\n";
# print out to STDOUT
$csv->print(\*STDOUT, \@rows); print "\n";

=end code

如果有人非要找你要 xls 格式的话,你可以简单的用一下 A<http://cpansearch.perl.org/src/HMBRAND/Text-CSV_XS-0.85/examples/csv2xls|csv2xls> 来转成 xls 给他们。(如果连接失效,可 google "csv2xls cpan")

但是如果他们需要一些特殊的 xls 功能的话,比如一些颜色,大小格式,或者 function 之类的,那我们就得求助于 M<Excel::Writer::XLSX> 了。

该模块由 M<Spreadsheet::WriteExcel> 的作者写的,相对 Spreadsheet::WriteExcel 提供了更好的性能和支持。

模块的使用也是非常简单的。(模块的使用都应该是很简单的,所有复杂的模块都是不合格的模块。:)

我们复制了 SYNOPSIS 过来。

=begin code

use Excel::Writer::XLSX;

# Create a new Excel workbook
my $workbook = Excel::Writer::XLSX->new( 'perl.xlsx' );

# Add a worksheet
$worksheet = $workbook->add_worksheet();

#  Add and define a format
$format = $workbook->add_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)' );

=end code

2个模块都有非常详细的 EXAMPLES 目录。如果还是不会的话,可以来 PerlChina Group 发帖求助。

谢谢。

--
Fayland Lam // http://www.fayland.org/

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。



--
            Yours Sincerely
                    Zeng Hong

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。



--
Fayland Lam // http://www.fayland.org/

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

Re: [PerlChina] 2011 CN Perl Advent Day 14: CSV & XLS

use Excel::Writer::XLSX
是不是支持 xls 2007 格式的
 
 

 
2011/12/14 Fayland Lam <fayland@gmail.com>
http://perlchina.github.com/advent.perlchina.org/2011/CSV_XLS.html 

=for advent_year 2011

=for advent_day 14

=for advent_title CSV & XLS

=for advent_author Fayland Lam

Well, 很多人都喜欢用 Excel or OpenOffice Calc 来打开表格文件。所以您的上司,客户或者朋友,会让你输出 csv 或者 xls 给他们。

有些人喜欢直接用 print join(', ', map { '"' . $_ . '"' } @outs) 来输出成 CSV, 但是这是极度不好的行为,因为 outs 里可能有 " 也可能有 ,

所以个人建议,不管是解析 CSV 或者构造 CSV, 都应该使用标准的 CPAN 模块。如 M<Text::CSV_XS>

=begin code

use Data::Dumper;
use Text::CSV_XS;
my $csv = Text::CSV_XS->new ({ binary => 1 }) or
    die "Cannot use CSV: " . Text::CSV_XS->error_diag();

# read
open(my $fh, "<:encoding(utf8)", "test.csv") or die "test.csv: $!";
while (my $row = $csv->getline($fh)) {
    print Dumper(\$row);
}
$csv->eof or $csv->error_diag();
close($fh);

# read from string
my $line = "myid,filename,size as 9mb";
unless ($csv->parse($line)) {
    die "Failed to parse $line: " . $csv->error_diag() . "\n";
}
my @field = $csv->fields;
print Dumper(\@field);

# print out to file
$csv->print($fh, ['myid', 'filename', 'size as 9mb']); print $fh "\n";
# print out to STDOUT
$csv->print(\*STDOUT, \@rows); print "\n";

=end code

如果有人非要找你要 xls 格式的话,你可以简单的用一下 A<http://cpansearch.perl.org/src/HMBRAND/Text-CSV_XS-0.85/examples/csv2xls|csv2xls> 来转成 xls 给他们。(如果连接失效,可 google "csv2xls cpan")

但是如果他们需要一些特殊的 xls 功能的话,比如一些颜色,大小格式,或者 function 之类的,那我们就得求助于 M<Excel::Writer::XLSX> 了。

该模块由 M<Spreadsheet::WriteExcel> 的作者写的,相对 Spreadsheet::WriteExcel 提供了更好的性能和支持。

模块的使用也是非常简单的。(模块的使用都应该是很简单的,所有复杂的模块都是不合格的模块。:)

我们复制了 SYNOPSIS 过来。

=begin code

use Excel::Writer::XLSX;

# Create a new Excel workbook
my $workbook = Excel::Writer::XLSX->new( 'perl.xlsx' );

# Add a worksheet
$worksheet = $workbook->add_worksheet();

#  Add and define a format
$format = $workbook->add_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)' );

=end code

2个模块都有非常详细的 EXAMPLES 目录。如果还是不会的话,可以来 PerlChina Group 发帖求助。

谢谢。

--
Fayland Lam // http://www.fayland.org/

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。



--
            Yours Sincerely
                    Zeng Hong

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

2011年12月14日星期三

Re: [PerlChina] 有好的perl调试器或者方法吗

试了下,这个好,很清晰。多谢。

======================================================
常福刚    规划设计中心-系统工程师
 
北京新媒传信科技有限公司
地  址:北京市朝阳区北苑路甲13号院1号楼北辰泰岳大厦16层
邮  编:100107
手  机:15901155677
E-Mail:changfugang@feinno.com
网  址:http://www.feinno.com

From: cnhack TNT
Sent: Wednesday, December 14, 2011 9:19 PM
Subject: Re: [PerlChina] 有好的perl调试器或者方法吗

可以参考一下 Devel::NYTProf 模块: https://metacpan.org/module/Devel::NYTProf

2011/12/14 fugang chang <fire_pot@hotmail.com>
hi,all
 
google到ptkdb工具,正在安装测试,不知道效果咋样~~
大家有没有好的perl调试器或者方法推荐下。
主要是想看下每步执行的时间,确定下优化的问题。谢谢。

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

Re: [PerlChina] 2011 CN Perl Advent Day 15: List::MoreUtils

Yes. it's quite powerful. another example for that is 'part'.

$ seq 1 30 | perl -MList::MoreUtils=part -lne 'push @all, $_; END{ $i; @sets=part {$i++ % 3} @all; print join q( ), q(/usr/bin/md5sum), @$f while $f = shift @sets }'
/usr/bin/md5sum 1 4 7 10 13 16 19 22 25 28
/usr/bin/md5sum 2 5 8 11 14 17 20 23 26 29
/usr/bin/md5sum 3 6 9 12 15 18 21 24 27 30


$ seq 1 30 | perl -MList::MoreUtils=natatime -lne 'push @all, $_; END{ $i=natatime 10, @all; print join q( ), q(/usr/bin/md5sum), @f while @f=$i->() }'
/usr/bin/md5sum 1 2 3 4 5 6 7 8 9 10
/usr/bin/md5sum 11 12 13 14 15 16 17 18 19 20
/usr/bin/md5sum 21 22 23 24 25 26 27 28 29 30

:)

2011/12/15 joe jiang <lamp.purl@gmail.com>
=for advent_year 2011

=for advent_day 15

=for advent_title List::MoreUtils

=for advent_author Joe Jiang

对于大多数人来说,列表的处理是最让人头疼的一件事了,因为循环、变量一类的逻辑非常难以调试。而 List::MoreUtils 则提供了一个简洁的接口,帮助我们进行高效的开发。

这里就用其中一个有用的函数 natatime 作为例子介绍这个常用的模块。

我们常常遇到的一个情况是,通过 Perl 生成 shell 脚本,然后用 shell 来执行。

=begin code

  % perl -le '...' > todo.sh
  % source todo.sh

=end code

如果 todo.sh 里面某一行有许多的参数,比如 md5sum 1.txt 2.txt ... 9999.txt,这就可能导致一个问题,那就是命令行过长:

=begin code

  % md5sum *
  -bash: /usr/bin/md5sum: Argument list too long

=end code

这样的问题,对于喜欢脚本的你来说,迟早会遇到的。natatime 这个有点大舌头的 not_a_time 函数能够帮助你去分批完成任务。

=begin code

  % seq 1 30 | perl -MList::MoreUtils=natatime -lne 'push @all, $_; END{ $i=natatime 10, @all; print join q( ), q(/usr/bin/md5sum), @f while @f=$i->() }'
  /usr/bin/md5sum 1 2 3 4 5 6 7 8 9 10
  /usr/bin/md5sum 11 12 13 14 15 16 17 18 19 20
  /usr/bin/md5sum 21 22 23 24 25 26 27 28 29 30

=end code

这里用 natatime(10, @all) 产生了一个 $i 引用的函数,然后反复调用函数,每次产生十个数据,用来生成最终的命令。

另一个有趣的例子是打印日历,如果你常常需要在命令行显示日历的话,可以用下面的代码实现:

=begin code

  #!/usr/bin/perl -l
  use List::MoreUtils qw(natatime);
  $it=natatime(7, (qw(Sun Mon Tue Wed Thr Fri Sat), (undef)x((8+@{[localtime]}[6]-@{[localtime]}[3]) % 7),map {s{^(@{[localtime]}[3])$}{\1*}; $_} (1..30)));
  print join qq(\t), @days while (@days=$it->())

=end code

运行效果如下:

=begin code

  Sun     Mon     Tue     Wed     Thr     Fri     Sat
                                  1       2       3
  4       5       6       7       8       9       10
  11      12      13      14      15*     16      17
  18      19      20      21      22      23      24
  25      26      27      28      29      30

=end code

需要承认的是,安装 Calendar::Simple 模块也能输出同样功能的脚本 pcal,但是这个脚本毕竟可以在 Windows 下运行。

更多例子可以参考 http://www.effectiveperlprogramming.com/。

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。



--
Fayland Lam // http://www.fayland.org/

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

[PerlChina] 2011 CN Perl Advent Day 15: List::MoreUtils

=for advent_year 2011

=for advent_day 15

=for advent_title List::MoreUtils

=for advent_author Joe Jiang

对于大多数人来说,列表的处理是最让人头疼的一件事了,因为循环、变量一类的逻辑非常难以调试。而 List::MoreUtils 则提供了一个简洁的接口,帮助我们进行高效的开发。

这里就用其中一个有用的函数 natatime 作为例子介绍这个常用的模块。

我们常常遇到的一个情况是,通过 Perl 生成 shell 脚本,然后用 shell 来执行。

=begin code

  % perl -le '...' > todo.sh
  % source todo.sh

=end code

如果 todo.sh 里面某一行有许多的参数,比如 md5sum 1.txt 2.txt ... 9999.txt,这就可能导致一个问题,那就是命令行过长:

=begin code

  % md5sum *
  -bash: /usr/bin/md5sum: Argument list too long

=end code

这样的问题,对于喜欢脚本的你来说,迟早会遇到的。natatime 这个有点大舌头的 not_a_time 函数能够帮助你去分批完成任务。

=begin code

  % seq 1 30 | perl -MList::MoreUtils=natatime -lne 'push @all, $_; END{ $i=natatime 10, @all; print join q( ), q(/usr/bin/md5sum), @f while @f=$i->() }'
  /usr/bin/md5sum 1 2 3 4 5 6 7 8 9 10
  /usr/bin/md5sum 11 12 13 14 15 16 17 18 19 20
  /usr/bin/md5sum 21 22 23 24 25 26 27 28 29 30

=end code

这里用 natatime(10, @all) 产生了一个 $i 引用的函数,然后反复调用函数,每次产生十个数据,用来生成最终的命令。

另一个有趣的例子是打印日历,如果你常常需要在命令行显示日历的话,可以用下面的代码实现:

=begin code

  #!/usr/bin/perl -l
  use List::MoreUtils qw(natatime);
  $it=natatime(7, (qw(Sun Mon Tue Wed Thr Fri Sat), (undef)x((8+@{[localtime]}[6]-@{[localtime]}[3]) % 7),map {s{^(@{[localtime]}[3])$}{\1*}; $_} (1..30)));
  print join qq(\t), @days while (@days=$it->())

=end code

运行效果如下:

=begin code

  Sun     Mon     Tue     Wed     Thr     Fri     Sat
                                  1       2       3
  4       5       6       7       8       9       10
  11      12      13      14      15*     16      17
  18      19      20      21      22      23      24
  25      26      27      28      29      30

=end code

需要承认的是,安装 Calendar::Simple 模块也能输出同样功能的脚本 pcal,但是这个脚本毕竟可以在 Windows 下运行。

更多例子可以参考 http://www.effectiveperlprogramming.com/。

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

[PerlChina] Fwd: Net::Evernote

---------- Forwarded message ----------
From: Ken Peng <shorttag@gmail.com>
Date: 2011/12/15
Subject: Net::Evernote
To: module-authors@perl.org


Hi,

I just created a project on CPAN Net::Evernote, it's the most original
0.01 version.

http://search.cpan.org/~yhpeng/Net-Evernote-0.01/lib/Net/Evernote.pm

Evernote's API is a big collection of functions, I don't have that
much time to implement all of them.

If you anybody has the interest with this project, please let me know,
we could co-work with it.

Thanks.

Ken.

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。