perl bug File :: Basename和Perl的性质 [英] perl bug File::Basename and Perl's nature

查看:49
本文介绍了perl bug File :: Basename和Perl的性质的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚在perl中遇到了另一种不负责任的行为。


此次犯罪是模块File :: Basename。


复制:


1.创建一个包含此名称文件的目录:" cdrom.html" ;.

2.使用File :: Basename; ,用行:

($ name,$ path,$ suffix)= fileparse($ File :: Find :: name,(''。html'',

''。m''));

3.请注意,您的cdrom.html将被解析为cdr带后缀

" om.html"。

咒骂Perl和Perl投掷蠢货。


现在,如果你仔细阅读文档 ofperldoc File :: Basename,

你会发现它不应该如此。而且,写作通常是

非常无能。为了说明,我引用:


- 开头报价


fileparse


fileparse(例程将一个文件分成三个部分:一个前导路径,一个

文件名和一个后缀。该路径包含

所有内容,包括输入文件规范中的最后一个目录

分隔符。

输入文件规范的剩余部分是

根据您在
中指定的

可选模式分为名称和后缀
@suffixlist。这个列表中的每个元素都可以是一个

qr-quoted模式(或者是一个字符串,它被解释为正则表达式的
),并且是

匹配名称的末尾。如果这个

成功,名称的匹配部分将被删除

并加上后缀。通过正确使用

@suffixlist,你可以删除文件类型或

版本进行检查。


--end quote


注意最后一句:通过正确使用@suffixlist,您可以删除

文件类型或版本以供检查。现在,这与unix手册的常用术语同步,提及不可饶恕的东西。

为什么他妈的我需要知道什么是版本或检查什么??

不是这个世界上的每个蠢货都在使用unix和它的morinic

将文件名附加到版本系统上的惯例,

并不是这个世界上的每个白痴都需要检查。的东西。 unix

不确定性,准确性,驱动性在上面进行了整理。


这是一个更好的文件,用于fileparse子程序。


fileparse


fileparse将文件名分为3部分:

目录字符串,文件名,文件名

后缀。 fileparse($ filename,@ suffixes)返回一个包含3个元素的
数组($ name,$ dir_path,

$ suffix)。

" dir_path $ name $ suffix"的结果保证等于

$ filename。 @suffixes是一个字符串数组,例如
(''\\\'',''\。txt'',''\ .png'')。这些

字符串被解释为常规

表达式,并与

$ filename结尾匹配。

但是NOOO,perl笨蛋太迷恋于写一些这样的功能规格,毕竟代码很邋and而且他们真的不知道
知道什么是代码确实如此。这不只是一个无能。

Perl充满了它们。


这个报告是关于Perl版本的:

这是perl,v5.8.1-RC3专为darwin-thread-multi-2级创建

(有1个注册补丁,详见perl -V)


-


对于那里的新手程序员,我建议不要学习Perl。

(我建议使用Python)请参阅
http://xahlee.org/UnixResource_dir/perlr.html


Xah
xa*@xahlee.org
http://xahlee.org/PageTwo_dir/more.html

Just bumped into another irresponsibility in perl.

the crime in question this time is the module File::Basename.

Reproduction:

1. create a directory containing a file of this name: "cdrom.html".
2. "use File::Basename;", with the line:
($name,$path,$suffix) = fileparse($File::Find::name, (''.html'',
''.m''));
3. Notice that your cdrom.html will be parsed into "cdr" with suffix
"om.html".

expletive Perl and Perl slinging morons.

Now, if you peruse the "documentation" of "perldoc File::Basename",
you''ll see that it shouldn''t be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:

--begin quote

fileparse

The fileparse() routine divides a file
specification into three parts: a leading path, a
file name, and a suffix. The path contains
everything up to and including the last directory
separator in the input file specification. The
remainder of the input file specification is then
divided into name and suffix based on the
optional patterns you specify in
@suffixlist. Each element of this list can be a
qr-quoted pattern (or a string which is
interpreted as a regular expression), and is
matched against the end of name. If this
succeeds, the matching portion of name is removed
and prepended to suffix. By proper use of
@suffixlist, you can remove file types or
versions for examination.

--end quote

Note the last sentence: "By proper use of @suffixlist, you can remove
file types or versions for examination." Now, this is in sync with the
usual verbiages of unix man pages, of mentioning irrevalent things.
Why the fuck do i need to know what is version, or examination what??
Not every morons in this world is using unix with its morinic
convention of appending things to file names as a versioning system,
and not every moron in this world need to "exam" things. The unix
irrevalency, inprecision, driveling are paragoned above.

Here is a better documentation for the fileparse subroutine.

fileparse

fileparse divides a file name into 3 parts:
directory string, file name, file name
suffix. fileparse($filename, @suffixes) returns a
array of 3 elements ($name, $dir_path,
$suffix). The concocted result of
"dir_path$name$suffix" is guaranteed to equal to
$filename. The @suffixes is a array of strings,
for example (''\.html'', ''\.txt'', ''\.png''). These
strings are interpreted to be regular
expressions, and is matched against the end of
$filename.
But NOOO, perl morons are too enamored with driveling to write such
functional spec, after all, the code is sloppy and they don''t REALLY
know what the code really does. This is not just one incompetence.
Perl is filled with them.

This report is on Perl version:
This is perl, v5.8.1-RC3 built for darwin-thread-multi-2level
(with 1 registered patch, see perl -V for more detail)

--

To the rookie programers out there, i advice against learning Perl.
(i suggest Python instead) Please see
http://xahlee.org/UnixResource_dir/perlr.html

Xah
xa*@xahlee.org
http://xahlee.org/PageTwo_dir/more.html

推荐答案

name,


path,


suffix)= fileparse(
suffix) = fileparse(


这篇关于perl bug File :: Basename和Perl的性质的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆