Chinaunix首页 | 论坛 | 博客
  • 博客访问: 837618
  • 博文数量: 253
  • 博客积分: 6891
  • 博客等级: 准将
  • 技术积分: 2502
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-03 11:01
文章分类

全部博文(253)

文章存档

2016年(4)

2013年(3)

2012年(32)

2011年(184)

2010年(30)

分类: Python/Ruby

2011-10-14 10:22:29

The File::Spec module is used for manipulating file specifications, which are the names
of files, directories, and the other things that are stored on filesystems. Like File::Base
name, it understands what kind of system it’s running on, and it chooses the right set
of rules every time. But unlike File::Basename, File::Spec is an object-oriented (often
abbreviated OO) module.
  1. use File::Spec;
  2. use File::Basename;

  3. chomp(my $filename = <STDIN>);
  4. $basename = basename $filename;
  5. $dirname = dirname $filename;

  6. ($newbase = $basename) =~ s/^/test/;

  7. $newfilename = File::Spec->catfile($dirname, $newbase);
  8. print $newfilename, "\n";
if input is "/home/user/test.txt", the output is "/home/user/testtest.txt".


a lot of methods are list in this model.

阅读(666) | 评论(0) | 转发(0) |
0

上一篇:PERL splice函数的用法

下一篇:CGI.pm

给主人留下些什么吧!~~