孤独的猫

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

2011年4月24日

摘要: 设有文件grade.txt, $pg grade.txt M.Tansley 05/99 48311 Green 8 40 44 J.Lulu 06/99 48317 green 9 24 26 P.Bunny 02/99 48 Yellow 12 35 28 J.Troll 07/99 4842 Brown-3 12 26 26 L.Tansley 05/99 4712 Brown-2 12 30 28 显示其内容,并输入到delete_me_and_die中 awk '{print $0}' grade.txt | tee delete_me_and_die,$0表示打印所有域 打印1,4域 阅读全文
posted @ 2011-04-24 18:13 孤独的猫 阅读(366) 评论(0) 推荐(0)

摘要: 有data.f文件 48 Dec 3BC1997 LPSX 68.00 LVX2A 138 483 Sept 5AP1996 USP 65.00 LVX2C 189 47 Oct 3ZL1998 LPSX 43.00 KVM9D 512 219 dec 2CC1999 CAD 23.00 PLV2C 68 484 nov 7PL1996 CAD 49.00 PLV2C 234 483 may 5PA1998 USP 37.00 KVM9D 644 216 sept 3ZL1998 USP 86.00 KVM9E 234 现统计含有"48"字符的行数 $grep -c "48" data.f 显示包含"48"字符串的文本 阅读全文
posted @ 2011-04-24 17:29 孤独的猫 阅读(246) 评论(0) 推荐(0)

摘要: #!/usr/bin/perl -w my @names=qw/ fred barney betty dino wilma pebbles bamm-bamm /; my $result=&which_element_is("dino",@names); 阅读全文
posted @ 2011-04-24 13:19 孤独的猫 阅读(226) 评论(0) 推荐(0)

摘要: #!/usr/bin/perl -wsub max{ my($max_so_far) = shift @_; #my后面用来声明私有变量,因为perl中默认都为公有变量,shift取列表的头元素,并删除头元素 foreach (@_) { if ($_ > $max_so_far) { $max_so_far = $_; } } $max_so_far;}$maximum=&max(3,5,10,4,6);print "The max is $maximum\n"; 阅读全文
posted @ 2011-04-24 13:11 孤独的猫 阅读(232) 评论(0) 推荐(0)

摘要: #!/usr/bin/perl -w sub sum_of_fred_and_barney { print "Hey,you called the sum_of_fred_and_barney subroutine!\n"; $fred+$barney; } 阅读全文
posted @ 2011-04-24 12:57 孤独的猫 阅读(250) 评论(0) 推荐(0)

摘要: #!/usr/bin/perl -w @rocks=qw; #qw后定义数组(列表),可用{},,/ /,或其他一对符号表示 # qw定义@rocks= ("bedrock","slate","lava") foreach $rock(@rocks){ $rock="\t$rock"; $rock.="\n"; } 阅读全文
posted @ 2011-04-24 12:52 孤独的猫 阅读(700) 评论(0) 推荐(0)

摘要: #!/usr/bin/perl -w $madonna=; if (defined($madonna)) { print "The input was $madonna"; } else { print "No input available!\n"; } 阅读全文
posted @ 2011-04-24 12:31 孤独的猫 阅读(252) 评论(0) 推荐(0)

摘要: #/usr/bin/perl -w $count=0; while ($count10){ $count+=2; print "count is now $count\n"; } 阅读全文
posted @ 2011-04-24 12:29 孤独的猫 阅读(255) 评论(1) 推荐(1)