use Smart::Comments; ### @args
2009/12/15 cnhack TNT <[email protected]> > 当你对某个数据结构有疑问的时候, 使用 Data::Dumper 直接将其结构打印出来加以分析是最便捷的 > 比如说你上面的 @args,何不这样: > ---- > #!/usr/bin/perl > > use Data::Dumper; > > > my $some = "This is a \t test.\n"; > my @args = split /\s+/,$some; > print Dumper \...@args; > > 这样 @args 里面啥样子就非常清楚了,特别是当数据结构比较复杂的时候(嵌套数组,嵌套哈希等等) > > 不过最需要的还是事先把 perl 的基本知识弄清楚, 多实验一下,多抄几下代码而已,不用搬砖的。 :-) > > 2009/12/15 Mai Sun <[email protected]> > > 那是你理解错了,书上写的不是打印的结果,你要想打印成那个样子你必须添加打印的样式。从数据的角度讲,你看到的就是你想要的输出。 >> >> 2009/12/15 天翼 张 <[email protected]> >> >> 我看的书就是perl语言入门(小骆驼第五版) >>> >>> On 12月15日, 下午3时35分, Xiaojun Deng <[email protected]> wrote: >>> > On Mon, Dec 14, 2009 at 09:52:54PM -0800, 天翼 张 wrote: >>> > >>> >按你的方法输出不了,而且按我学习的书上的这个代码,出来的结果应该是把空格全换成逗号。每个单词再加上双引号,可是我按书的代码写出来后出来的不是希 >>> > >望要的结果。 >>> > >>> > Which book? I think the book is wrong. >>> > print "@array" can split the word, but no comma. >>> > Actually, learning the Perl is a good choicehttp:// >>> www.amazon.com/Learning-Perl-Fourth-Randal-Schwartz/dp/0596101058 >>> > chinese translatehttp:// >>> product.dangdang.com/product.aspx?product_id=20696203 >>> > >>> > >>> > >>> > >>> > >>> > >On 12月15日, 上午7时10分, constra <[email protected]> wrote: >>> > >> 你所看到的Thisisatest已经是split作用过的结果了。 >>> > >> 你可以试试$args[1]输出的是不是is >>> > >>> > >> On 12月14日, 下午2时37分, 天翼 张 <[email protected]> wrote: >>> > >>> > >> > 各位高手好: >>> > >> > >>> 我在学习perl过程中,当学到用split这一节时,按照书上的方法输入代码。可是却显示不了正确的结果。所以想请教一下怎么使用 >>> > >> > split关键字。以下是我的代码: >>> > >> > #!/usr/bin/perl >>> > >> > my $some = "This is a \t test.\n"; >>> > >> > my @args = split /\s+/,$some; >>> > >> > print @args; >>> > >> > 本来应该显示的是#This","is","a","test".";可是事实上在我的命令提示符上显示的是Thisisatest. >>> > >> > 不知道是怎么回事,是不是现在这个split不能用了呀? >>> > >>> > >-- >>> > >>> > >您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。 >>> > >要向此网上论坛发帖,请发送电子邮件至 [email protected]。 >>> > >要取消订阅此网上论坛,请发送电子邮件至 >>> > >[email protected]<perlchina%[email protected]> >>> 。 >>> > >若有更多问题,请通过http://groups.google.com/group/perlchina?hl=zh-CN访问此网上论坛。 >>> > >>> > -- >>> > [32m《将进酒》 [m >>> > [33m作者:李白 [m >>> > 君不见,黄河之水天上来,奔流到海不复回。 >>> > 君不见,高堂明镜悲白发,朝如青丝暮成雪。 >>> > 人生得意须尽欢,莫使金樽空对月。 >>> > 天生我材必有用,千金散尽还复来。 >>> > 烹羊宰牛且为乐,会须一饮三百杯。 >>> > 岑夫子,丹丘生,将进酒,君莫停。 >>> > 与君歌一曲,请君为我侧耳听。 >>> > 钟鼓馔玉不足贵,但愿长醉不愿醒。 >>> > 古来圣贤皆寂寞,惟有饮者留其名。 >>> > 陈王昔时宴平乐,斗酒十千恣欢谑。 >>> > 主人何为言少钱,径须沽取对君酌。 >>> > 五花马,千金裘,呼儿将出换美酒, >>> > 与尔同销万古愁。 >>> >>> -- >>> >>> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 >>> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 >>> 要取消订阅此网上论坛,请发送电子邮件至 >>> [email protected]<perlchina%[email protected]> >>> 。 >>> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 >>> >>> >>> >> -- >> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 >> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 >> 要取消订阅此网上论坛,请发送电子邮件至 >> [email protected]<perlchina%[email protected]> >> 。 >> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 >> > > -- > 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 > 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 > 要取消订阅此网上论坛,请发送电子邮件至 > [email protected]<perlchina%[email protected]> > 。 > 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 > -- 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
