perl

使用userdel命令删除Linux用户

人盡茶涼 提交于 2020-12-04 23:55:43
userdel是什么 userdel 是一个底层用于删除用户的工具。在 Debian 上,我们通常会使用 deluser 命令。userdel 会查询系统账户文件,例如 /etc/password 和 /etc/group。那么它会删除所有和用户名相关的条目。在我们删除它之前,用户名必须存在。 如何使用userdel 由于 userdel 会修改系统账户文件,那么我们需要root特权来运行它。不然我们会遇到一个报错信息“只有root权限才能执行这项操作”或者类似的信息。在我们得到特权后,我们可以通过输入 userdel 从你的控制台删除用户。下面是一个默认使用 userdel 的样例。 $ sudo userdel pasadena 或者 # userdel pasadena 正如你所见,我们不能没有root权限而删除用户 pasadena。当我们有权限时,系统不会给出错误信息,这意味着用户已经成功删除。 完全删除用户家目录 不带选项使用 userdel,只会删除用户。用户的家目录将仍会在/home目录下。 当我们进入/home目录时,我们仍旧可以看到ID 1002拥有 pasadena 文件夹。已创建的用户通常会有一个与用户名相同的组名。1002是 pasadena 用户名的 UID 和 pasadena 组名的 GID。 为了在删除用户时完全删除家目录,我们可以使用 -r 选项

2019编程语言排行榜

寵の児 提交于 2020-12-04 15:54:30
TIOBE 7 月份的编程语言排行榜已经公布,官方的标题是 Perl 是Python 热度过高的受害者之一 ,Python 最近确实是挺热的,大家可以看到最近 Python 相关培训课程的广告投放,不管在微信还是网站上都有它们的身影。 Perl 这个语言还是很有历史渊源的,不过现在应该很少人会去学,它最大的优势应该是 强大的正则表达式和模式匹配功能 。 Perl 目前位于 TIOBE 排行榜的第 19 位,这是 Perl 的历史最低点,2005 年的时候是 Perl 的高光时刻,那时候排在整个榜单的第三位。 另外, 7 月排名前十的分别是:Java, C, Python, C++, C#, Visual Basic .NET, JavaScript, PHP, SQL 和汇编语言。和上个月的不同之处主要是 C# 以微弱的优势超过了 Visual Basic .NET 的排名,再次进入 TOP 5,而宇宙语言 PHP 下滑到第八位。 Java 的地位依然稳定,国内应用最大的应该是阿里,它们也出了 Java 开发手册,制定了一些开发规范,很值得学习借鉴。感兴趣的可以去这里下载 https://github.com/alibaba/p3c 。 Python 的指数从上个月的 8.530% 上升到本月的 9.260%,应该还会持续上升。 排名 1-20 的编程语言 排名 21-50

How to set two appenders with different log levels in Log::Log4perl?

百般思念 提交于 2020-12-04 02:20:33
问题 I have a logger with two appenders (one Screen and other File). I want to have a Screen appender with a variable log level that can be changed and File appender that will log everything no matter what. So for instance, you can disable any output to screen (Screen appender) but get full logging to the level of TRACE in your logfile (File appender). I succeeded in getting changing Screen appender but I can't set File appender for the same logger to the level of TRACE. I tried using different

count number of files in a folder with perl

Deadly 提交于 2020-12-03 07:34:30
问题 I would like to count the number of files inside a folder with perl. With the following code I can list them, but i don't know how to count them in perl. Any help? $dir = "/home/Enric/gfs-0.5.2016061400"; opendir(DIR, "$dir"); @FILES = grep { /gfs./ } readdir(DIR); foreach $file (@FILES) { print $file, "\n"; } closedir(DIR); 回答1: If you want to just count them, once you have a directory open for reading you can manipulate context on readdir so that it returns the list of all entries, and then

count number of files in a folder with perl

冷暖自知 提交于 2020-12-03 07:34:05
问题 I would like to count the number of files inside a folder with perl. With the following code I can list them, but i don't know how to count them in perl. Any help? $dir = "/home/Enric/gfs-0.5.2016061400"; opendir(DIR, "$dir"); @FILES = grep { /gfs./ } readdir(DIR); foreach $file (@FILES) { print $file, "\n"; } closedir(DIR); 回答1: If you want to just count them, once you have a directory open for reading you can manipulate context on readdir so that it returns the list of all entries, and then

程序员 45 岁怎么了?!

烂漫一生 提交于 2020-12-01 07:17:45
对于众多程序员而言,年龄一直是一个让自己不由得焦虑的话题,一是随着年龄的增长,如何保持旺盛的学习精力,再者,国内互联网公司对于年轻的倡导。 事实上,国外许多开发者也面临着同样的问题。本文作者 Ben Sinclair 是一个已经 45 岁的开发者,他分享了自己的所遇以及思考,也许会让你有所受益。 作者 | Ben Sinclair,C、Perl、PHP 及 Python 开发者 译者 | 风车云马,责编 | 唐小引 出品 | CSDN(ID:CSDNnews) 以下为译文: 我叫 Ben,我是一名开发人员,而且……我老了。 今年我 45 岁了,可能很多开发者都会说,我老了。实际上,对于很多从事不同工作的人来说,这算是步入职业生涯的中期。 最近读了一篇文章令我陷入了深深的思考。 如果我是一名职业运动员,也许已经过了巅峰时期。但作为一名水管工呢?并非如此。为什么全世界都认为开发人员属于前一类职业呢? 1 对老年人的歧视 曾经有家本地公司向我们 Python 群发送了一封招聘邮件。如果这不是经常性的,而且与我们专业相关的,其实我们也并不完全讨厌这些邮件。 这封邮件开始写道: 我们是一个充满朝气的团队,正在寻找一位年轻、热情的开发人员来…… 我们的一位老成员看到后点击了“reply-to-all(回复全部)”,我还能感受到他的愤怒。人们很容易就会那样说话。年轻意味着锋芒,年轻意味着优势。

Getopts to flag bad options without dash

☆樱花仙子☆ 提交于 2020-11-29 09:56:48
问题 Getopt::Long::Configure("no_pass_through"); my %opts = (); GetOptions(\%opts, 'opt1=s', 'opt2=s', 'opt3' ); test.pl bad_option_without_dash How do I make getopts flag an error when a bad option is passed without a dash? I was expecting that no_pass_through will take care of this. What am I missing? 回答1: Getopt::Long just extracts the options. It's up to you to validate the value of those options and the non-option arguments (which are left in @ARGV ). Specifically, if you want to make sure

Getopts to flag bad options without dash

|▌冷眼眸甩不掉的悲伤 提交于 2020-11-29 09:56:12
问题 Getopt::Long::Configure("no_pass_through"); my %opts = (); GetOptions(\%opts, 'opt1=s', 'opt2=s', 'opt3' ); test.pl bad_option_without_dash How do I make getopts flag an error when a bad option is passed without a dash? I was expecting that no_pass_through will take care of this. What am I missing? 回答1: Getopt::Long just extracts the options. It's up to you to validate the value of those options and the non-option arguments (which are left in @ARGV ). Specifically, if you want to make sure

开发者在 M1 Mac 上成功虚拟化运行了 Arm 版本的 Windows

倾然丶 夕夏残阳落幕 提交于 2020-11-29 09:14:30
开发者在 M1 Mac 上成功虚拟化运行了 Arm 版本的 Windows 这证明 M1 芯片能够运行微软的操作系统。开发者表示,当在 M1 Mac 上进行虚拟化时,“Windows ARM64 可以很好地运行 x86 应用程序。虽然没有 Rosetta 2 那么快,但也接近了”。 目前,采用 M1 芯片的 Mac 不支持 Windows,也没有像英特尔的 Mac 那样的 Boot Camp 功能,但支持 Windows 是很多用户希望看到的功能。 利用开源的 QEMU 虚拟机,开发者能够在苹果 M1 芯片上虚拟出 Arm 版本的 Windows,而且没有使用仿真。由于 M1 芯片是定制的 Arm SoC,因此无法再像之前基于英特尔的 Mac 那样,使用 Boot Camp 安装 x86 版 Windows 或 Windows 应用。 来源: macrumors 拍一拍:这真是一个好消息,想必不久各种虚拟机软件就会跟进了。 Perl 项目治理新规 Perl 语言项目的新治理模式已接近成型。 Python 项目的治理模式与 Python 项目采用的模式相似,将由两个实体参与治理:一个由几十人组成的核心团队,以及一个三人组成的指导委员会。核心团队制定规则,投票选出两个团队的成员,将实质性的决策权授予指导委员会。指导委员会有着广泛的权力,可以对语言、解释器和其它组件的开发做决定。 来源:

How do I match across newlines in a perl regex?

流过昼夜 提交于 2020-11-29 08:35:43
问题 I'm trying to work out how to match across newlines with perl (from the shell). following: (echo a b c d e; echo f g h i j; echo l m n o p) | perl -pe 's/(c.*)/[$1]/' I get this: a b [c d e] f g h i j l m n o p Which is what I expect. But when I place an /s at the end of my regex, I get this: a b [c d e ]f g h i j l m n o p What I expect and want it to print is this: a b [c d e f g h i j l m n o p ] Is the problem with my regex somehow, or my perl invocation flags? 回答1: -p loops over input