2007年8月20日星期一

在Perl中获取当前目录的完整路径

有两种方法:
1. use Cwd;
my $dir = getcwd;
#$dir中即为当前目录的完整路径信息。

2. my $dir = $ENV{'PWD'};
#ENV是一个散列,用于存放环境变量。$PWD是Linux的环境变量,表示当前所在目录。

若当前目录为/usr/lib/, 则上面的$dir = /usr/lib

4 条评论:

Unknown 说...

hi Jerry
你知道如何在数组元素中进行替换操作吗?
比如有一个txt文件,列之间用space分隔
然后第6个列的元素,我想做个替换,这该怎么操作呢,整个文件很大

第六个column的内容如下,但是我只想要前面的这个数字,即95.3514747314008
后面的就不要了
这样替换怎么替换呢
谢谢
欢迎发email给我哈,qyodan@gmail.com

95.3514747314008 // D4S1542 // D4S2929 // --- // --- /// 95.869410402114 // D4S1534 // D4S2929 // AFM155XE11 // AFMA224WC5 /// 95.8435547202882 // --- // --- // 260346 // 260791

匿名 说...

[B]NZBsRus.com[/B]
Dont Bother With Slow Downloads Using NZB Files You Can Quickly Search HD Movies, PC Games, MP3s, Applications and Download Them @ Flying Speeds

[URL=http://www.nzbsrus.com][B]Newsgroup[/B][/URL]

匿名 说...

Accept to pass the unaware of with two backs casinos? wind up this advanced [url=http://www.realcazinoz.com]casino[/url] counsel and wing it curb online casino games like slots, blackjack, roulette, baccarat and more at www.realcazinoz.com .
you can also quarters our lately [url=http://freecasinogames2010.webs.com]casino[/url] manipulate at http://freecasinogames2010.webs.com and sketch genuine to memoirs folding spondulix !
another solo confinement [url=http://www.ttittancasino.com]casino spiele[/url] emplacement is www.ttittancasino.com , as opposed to of german gamblers, get not hustling online casino bonus.

匿名 说...

[url=http://www.casino-online.gd]Online casinos[/url], also known as accepted casinos or Internet casinos, are online versions of renowned ("chunk and mortar") casinos. Online casinos plump excepting gamblers to ownership lines in and wager on casino games downright the Internet.
Online casinos normally incitement probability on the securities dealing odds and payback percentages that are comparable to land-based casinos. Some online casinos identify higher payback percentages during chore defender games, and some coach the expos‚ almost payout schedule audits on their websites. Assuming that the online casino is using an aptly programmed unspecific hundred generator, facts games like blackjack take an established train edge. The payout cut down up after these games are established to the nucleus the rules of the game.
Uncountable online casinos agreement broken or grip their software from companies like Microgaming, Realtime Gaming, Playtech, Supranational Imposture Technology and CryptoLogic Inc.