以下Function Compute某年份是否為閏年#!/usr/bin/perl$my_year = 2000;if ( is_leap_year( $my_year ) ){ # Call function with an argument print "$my_year is a leap year\n";}else{ print "$my_year is not a leap year";}sub is_leap_year { # Function definition
1、讀取某檔案,如果該檔案不存在,則報錯,並提示出錯原因open (DB, "/home/ellie/myfile") or die "Can't open file: $!\n"; 運行後提示:Can't open file: No such file or director 2、讀寫檔案的方法:open(FH, "<filename"); # Opens "filename" for reading.讀 # The <
一些常用模組的簡單描述 http://www.perldoc.com/perl5.6/pod/perlmodlib.html在perl 中使用模組: 模組的:http://www.cpan.org/modules/01modules.index.html 安裝模組: 1. perl Makefile.PL 2. make 3. make test 4. make install 也可以用如下命令安裝模組(已知的適用的系統redhat 9.0,其他的我不知道,請大家試試看 。 perl
Making References References can be created in several ways.By using the backslash operator on a variable, subroutine, or value. (This works much like the & (address-of) operator in C.) This typically creates another reference to a variable,
由於CME極有個性,終於開掉她,忽然發現CMO的工作有太多還沒有做,Version Controlling, Change Management,Auto Release, Configuration Status Announce. 當務之急,Key Area List , find out that ,Auto Release is important thing. 1.首先解決整體的設計:
由於linux上處理word和ppt比較麻煩,而且有檔案格式專利的問題,所以以下操作全部在Windows下面進行。首先需要安裝Microsoft Save as PDF附加元件,官方:http://www.microsoft.com/zh-cn/download/details.aspx?id=7安裝成功後可以手工將文檔另存新檔pdf。需要引用“Win32::OLE”模組use Win32::OLE;use Win32::OLE::Const 'Microsoft Word';use Win32
經常要講一個檔案分割成許多小檔案,如果每次判斷後要進行“開啟檔案控制代碼—》寫入資料—》關閉檔案控制代碼”,這樣重複的開啟、關閉檔案控制代碼是很耗時間的。進程經常會處於“S”睡眠狀態。如果同時開啟多個檔案,再判斷要寫入哪個檔案,則可以節省CPU等待的時間。for my $i (0..99){ $o="OUT".$i; open $o,">test.$i" or die $!; print $o "test"; close
方法一: 5.8版本 使用Switch包 use Switch; switch ($val) { case 1 { print "number 1" } case "a" { print "string a" } case [1..10,42] { print "number in list" } case (@array) { print "number