我只找到了这些帖子,问题是相反的。我在日常使用或 shell 脚本中经常使用(或我想要)Perl,但每次它都会让我兴奋,因为我知道为了让我的脚本工作,我首先需要安装 Perl。有人可以分享一些关于为什么 Ubuntu 会出现这种情况的信息吗?
我从 Ubuntu v18 完全升级到 Ubuntu v20。
快门未升级 - 它已被移除。我试图从CRAN或源代码安装。两者都抱怨旧的 Perl 库。
当我试图从源代码编译并运行它时,这是我得到的消息......我在某处读到我可以在我的系统中安装两个 Perl。但是,我不知道问题是否属于那种类型——它需要旧版本的 Perl 还是路径问题?
使用 find / search 我找不到文件“always.pm”(几分钟后,我打破了它)。
shutter
结果:
Can't locate Carp/Always.pm in @INC (you may need to install the Carp::Always module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/local/bin/shutter line 39.
BEGIN failed--compilation aborted at /usr/local/bin/shutter line 39 (#1)
(F) You said to do (or require, or use) a file that couldn't be found.
Perl looks for the file in all the locations mentioned in @INC, unless
the file name included the full path to the file. Perhaps you need
to set the PERL5LIB or PERL5OPT environment variable to say where the
extra library is, or maybe the script needs to add the library name
to @INC. Or maybe you just misspelled the name of the file. See
"require" in perlfunc and lib.
Uncaught exception from user code:
Can't locate Carp/Always.pm in @INC (you may need to install the Carp::Always module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/local/bin/shutter line 39.
BEGIN failed--compilation aborted at /usr/local/bin/shutter line 39.
通过发行
sudo apt-get install --reinstall libcarp-always-perl
结果(甚至删除了hugin。我没有太大变化,我不希望它被删除):
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
hugin : Depends: libglew2.0 (>= 1.12.0) but it is not installable
Depends: libomp5 (>= 0.20140926) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
通过发出:
sudo apt --fix-broken install
结果:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
libtiff4 libtiffxx0c2
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
hugin
0 upgraded, 0 newly installed, 1 to remove and 15 not upgraded.
1 not fully installed or removed.
After this operation, 275 MB disk space will be freed.
Do you want to continue? [Y/n] n
Abort.
通过发布(存储库已经存在)
sudo apt dist-upgrade
结果是:
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
hugin : Depends: libglew2.0 (>= 1.12.0) but it is not installable
Depends: libomp5 (>= 0.20140926) but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
注意: Hugin 是从源代码编译的,带有我需要的手动标志。我不想从官方存储库安装它,因为它缺少这些特殊标志(使用额外的处理能力)。但是,我试图删除它,但同样没有运气。
通过运行
sudo add-apt-repository ppa:linuxuprising/shutter
sudo apt-get update
sudo apt-get install shutter
结果是:
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
hugin : Depends: libglew2.0 (>= 1.12.0) but it is not installable
Depends: libomp5 (>= 0.20140926) but it is not going to be installed
shutter : Depends: libgtk3-imageview-perl (>= 9) but it is not going to be installed
Depends: libgoocanvas2-perl but it is not going to be installed
Depends: libnumber-bytes-human-perl but it is not going to be installed
Depends: libcarp-always-perl but it is not going to be installed
Depends: libgoocanvas2-cairotypes-perl but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
通过运行:
sudo apt-get install shutter
结果是:
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
hugin : Depends: libglew2.0 (>= 1.12.0) but it is not installable
Depends: libomp5 (>= 0.20140926) but it is not going to be installed
shutter : Depends: libgtk3-imageview-perl (>= 9) but it is not going to be installed
Depends: libgoocanvas2-perl but it is not going to be installed
Depends: libnumber-bytes-human-perl but it is not going to be installed
Depends: libcarp-always-perl but it is not going to be installed
Depends: libgoocanvas2-cairotypes-perl but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
通过运行
sudo apt-cache policy hugin shutter libomp5 libglew2.0 shutter libgtk3-imageview-perl libgl1
结果是:
hugin:
Installed: 2019.3.0.8297
Candidate: 2020.0.0-0b1~focal
Version table:
2020.0.0-0b1~focal 500
500 http://ppa.launchpad.net/ubuntuhandbook1/apps/ubuntu focal/main amd64 Packages
*** 2019.3.0.8297 100
100 /var/lib/dpkg/status
2019.2.0+dfsg-1build3 500
500 http://ftp.ntua.gr/ubuntu focal/universe amd64 Packages
shutter:
Installed: (none)
Candidate: 0.97-1~0linuxuprising1~focal1
Version table:
0.97-1~0linuxuprising1~focal1 500
500 http://ppa.launchpad.net/linuxuprising/shutter/ubuntu focal/main amd64 Packages
500 http://ppa.launchpad.net/linuxuprising/shutter/ubuntu focal/main i386 Packages
0.94-1 -1
100 /var/lib/dpkg/status
libomp5:
Installed: (none)
Candidate: 1:10.0-50~exp1
Version table:
1:10.0-50~exp1 500
500 http://ftp.ntua.gr/ubuntu focal/universe amd64 Packages
libglew2.0:
Installed: (none)
Candidate: (none)
Version table:
shutter:
Installed: (none)
Candidate: 0.97-1~0linuxuprising1~focal1
Version table:
0.97-1~0linuxuprising1~focal1 500
500 http://ppa.launchpad.net/linuxuprising/shutter/ubuntu focal/main amd64 Packages
500 http://ppa.launchpad.net/linuxuprising/shutter/ubuntu focal/main i386 Packages
0.94-1 -1
100 /var/lib/dpkg/status
libgtk3-imageview-perl:
Installed: (none)
Candidate: 9-1~ppa~focal4
Version table:
9-1~ppa~focal4 500
500 http://ppa.launchpad.net/linuxuprising/shutter/ubuntu focal/main amd64 Packages
500 http://ppa.launchpad.net/linuxuprising/shutter/ubuntu focal/main i386 Packages
libgl1:
Installed: 1.3.2-1~ubuntu0.20.04.1
Candidate: 1.3.2-1~ubuntu0.20.04.1
Version table:
*** 1.3.2-1~ubuntu0.20.04.1 500
500 http://ftp.ntua.gr/ubuntu focal-updates/main amd64 Packages
100 /var/lib/dpkg/status
1.3.1-1 500
500 http://ftp.ntua.gr/ubuntu focal/main amd64 Packages
按照 N0bert 的说明进行操作:
sudo ppa-purge ppa:ubuntuhandbook1/apps
结果是:
Updating packages lists
PPA to be removed: ubuntuhandbook1 apps
Package revert list generated:
audacious/focal audacious-plugins:amd64/focal audacious-plugins-data/focal libaudcore5:amd64/focal libaudgui5:amd64/focal libaudqt2:amd64- libaudtag3:amd64/focal
vokoscreen-ng/focal
Disabling ubuntuhandbook1 PPA from /etc/apt/sources.list.d/ubuntuhandbook1-ubuntu-apps-bionic.list
Disabling ubuntuhandbook1 PPA from /etc/apt/sources.list.d/ubuntuhandbook1-ubuntu-apps-focal.list
Updating packages lists
Reading package lists... Done
Building dependency tree
Reading state information... Done
Selected version '3.10.1-1build1' (Ubuntu:20.04/focal [amd64]) for 'audacious'
Selected version '3.10.1-1build2' (Ubuntu:20.04/focal [amd64]) for 'audacious-plugins'
Selected version '3.10.1-1build2' (Ubuntu:20.04/focal [all]) for 'audacious-plugins-data'
Selected version '3.10.1-1build1' (Ubuntu:20.04/focal [amd64]) for 'libaudcore5'
Selected version '3.10.1-1build1' (Ubuntu:20.04/focal [amd64]) for 'libaudgui5'
Selected version '3.10.1-1build1' (Ubuntu:20.04/focal [amd64]) for 'libaudtag3'
Selected version '3.0.2-1' (Ubuntu:20.04/focal [amd64]) for 'vokoscreen-ng'
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
hugin : Depends: libglew2.0 (>= 1.12.0) but it is not installable
Depends: libomp5 (>= 0.20140926) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
The following packages will be DOWNGRADED:
audacious audacious-plugins audacious-plugins-data libaudcore5 libaudgui5 libaudtag3 vokoscreen-ng
The following packages will be REMOVED:
libaudqt2 libtiffxx0c2{u}
The following partially installed packages will be configured:
hugin{b}
0 packages upgraded, 0 newly installed, 7 downgraded, 2 to remove and 7 not upgraded.
Need to get 2,460 kB of archives. After unpacking 1,705 kB will be freed.
The following packages have unmet dependencies:
hugin : Depends: libglew2.0 (>= 1.12.0) which is a virtual package and is not provided by any available package
Depends: libomp5 (>= 0.20140926) but it is not going to be installed
The following actions will resolve these dependencies:
Remove the following packages:
1) hugin [2019.3.0.8297 (now)]
Accept this solution? [Y/n/q/?]
按“y”后,我可以安装快门
sudo apt-get install shutter
听从 N0bert 的指示,我也是如何保留 Hugin 的……
cd ~/Downloads
wget -c http://old-releases.ubuntu.com/ubuntu/pool/universe/t/tiff3/libtiff4_3.9.7-2ubuntu1_amd64.deb
wget -c https://mirrors.aliyun.com/oldubuntu-releases/ubuntu/pool/main/e/eglibc/multiarch-support_2.15-0ubuntu10.23_amd64.deb
sudo apt-get install -y ./libtiff4_3.9.7-2ubuntu1_amd64.deb ./multiarch-support_2.15-0ubuntu10.23_amd64.deb
wget -c http://archive.ubuntu.com/ubuntu/pool/universe/g/glew/libglew2.0_2.0.0-5_amd64.deb
sudo apt-get install -y ./libglew2.0_2.0.0-5_amd64.deb
sudo apt --fix-broken install
sudo apt autoremove --purge
cd ~/Downloads
wget -c http://old-releases.ubuntu.com/ubuntu/pool/universe/t/tiff3/libtiff4_3.9.7-2ubuntu1_amd64.deb
wget -c https://mirrors.aliyun.com/oldubuntu-releases/ubuntu/pool/main/e/eglibc/multiarch-support_2.15-0ubuntu10.23_amd64.deb
sudo apt-get install -y ./libtiff4_3.9.7-2ubuntu1_amd64.deb ./multiarch-support_2.15-0ubuntu10.23_amd64.deb
wget -c http://archive.ubuntu.com/ubuntu/pool/universe/g/glew/libglew2.0_2.0.0-5_amd64.deb
sudo apt-get install -y ./libglew2.0_2.0.0-5_amd64.deb
sudo apt-get install -y ./libtiff4_3.9.7-2ubuntu1_amd64.deb
sudo apt-get install ~/src/hugin/hugin.build/hugin-2019.3.0.8297-Linux.deb
sudo apt-get install libsz2
wget -c http://archive.ubuntu.com/ubuntu/pool/universe/h/hdf5/libhdf5-100_1.10.0-patch1+docs-4_amd64.deb
dpkg -x libhdf5-100_1.10.0-patch1+docs-4_amd64.deb /tmp/hdf
sudo cp /tmp/hdf/usr/lib/x86_64-linux-gnu/libhdf5_serial.so.100 /usr/local/lib
sudo rm /usr/lib/libhdf5_serial.so.100
sudo apt install libhdf5-103
sudo apt install libhdf5-103 --reinstall
我想使用 Perl 脚本以两位小数写数字。这是我的代码。
#!/usr/bin/perl -w
print "Preparing input files\n";
$incr=0.10;
&prepare_input();
exit(0);
sub prepare_input() {
$dist=3;
while ($dist <= 23) {
print "Processing distral: $dist\n";
&write_mdin0();
&write_mdin1();
&write_mdin2();
&write_disang();
$dist += $incr;
}
}
sub write_mdin0 {
open MDINFILE,'>', "min_mdin.$dist";
print MDINFILE <<EOF;
#5000 step minimization for $dist ang
&cntrl
imin = 1,
maxcyc=10000, ncyc = 5000,
ntpr = 100, ntwr = 1000,
ntf = 1, ntc = 1, cut = 10.0,
ntb = 1, ntp = 0,
nmropt = 1,
&end
&wt
type='END',
&end
DISANG=disang.$dist
EOF
close MDINFILE;
}
sub write_mdin1 {
open MDINFILE,'>', "equi_mdin.$dist";
print MDINFILE <<EOF;
#10 ns NVT equilibration for $dist ang
&cntrl
imin = 0, ntx = 1, irest = 0,
iwrap = 1,
ntpr = 5000, ntwr = 50000, ntwx = 0,
ntf = 2, ntc = 2, cut = 10.0,
ntb = 2, nstlim = 5000000, dt = 0.002,
tempi=0.0, temp0 = 300.0, ntt = 3,
gamma_ln = 5.0,
ntp = 1, pres0 = 1.0, taup = 5.0,
nmropt = 1, ioutfm=1,
&end
&wt
type='END',
&end
DISANG=disang.$dist
EOF
close MDINFILE;
}
sub write_mdin2 {
open MDINFILE,'>', "prod_mdin.$dist";
print MDINFILE <<EOF;
#20 ns NPT production for $dist ang
&cntrl
imin = 0, ntx = 5, irest = 1,
iwrap = 1,
ntpr = 10000, ntwr = 10000, ntwx = 10000,
ntf = 2, ntc = 2, cut = 10.0,
ntb = 2, nstlim = 10000000, dt = 0.002,
temp0 = 300.0, ntt = 3,
gamma_ln = 5.0,
ntp = 1, pres0 = 1.0, taup = 5.0,
nmropt = 1, ioutfm = 1,
&end
&wt
type='DUMPFREQ', istep1=10,
&end
&wt
type='END',
&end
DISANG=disang.$dist
DUMPAVE=distance_$dist.dat
EOF
close MDINFILE;
}
sub write_disang {
$min = sprintf "%4.6f", $dist;
open DISANG,'>', "disang.$dist";
print DISANG <<EOF;
#Harmonic restraints for $dist ang
&rst iat=-1,-1,0
r1=0.000000, r2=$min, r3=$min, r4=99.000000, rk2=5.00000, rk3=5.00000,
IGR1(1)=1,IGR1(2)=5,IGR1(3)=17,IGR1(4)=19,IGR1(5)=21,IGR1(6)=34,IGR1(7)=36,IGR1(8)=38,IGR1(9)=53,IGR1(10)=55,IGR1(11)=57,IGR1(12)=69,IGR1(13)=71,IGR1(14)=73,IGR1(15)=90,IGR1(16)=92,IGR1(17)=94,IGR1(18)=112,
IGR2(1)=116,IGR2(2)=120,IGR2(3)=132,IGR2(4)=134,IGR2(5)=136,IGR2(6)=149,IGR2(7)=151,IGR2(8)=153,IGR2(9)=168,IGR2(10)=170,IGR2(11)=172,IGR2(12)=184,IGR2(13)=186,IGR2(14)=188,IGR2(15)=205,IGR2(16)=207,IGR2(17)=209,IGR2(18)=227,
nstep1=0, nstep2=0,
&end
EOF
close DISANG;
}
这些代码生成这种文件:
min_mdin.8.99999999999998
min_mdin.9.09999999999998
我的目标是生成以下类型的文件:
min_mdin.9.00
min_mdin.9.10
我有一个标准输出或文件无关紧要:
mela
pera
banana
caffè
mela
pera
banana
caffè
mela
pera
banana
caffè
我只想删除最后一次出现的“ mela
”,使用perl
:
mela
pera
banana
caffè
mela
pera
banana
caffè
pera
banana
caffè
我该怎么做?
链接
没有帮助我。
我尝试过使用 Python:
import os
line='ID_SN=02 MS=DC:A6:32:7E:74:08 S=* TS=24/11/2020 11:02:30 CET N=IMC2500 MD=7F:7A:25:43:8F:44 T=LE P=90@'
cmd1="perl -sni -e 'print unless /^\Q$regex\E$/' -- -regex=%s device_scan.txt" % repr(line)
os.system(cmd1)
但是\Q
......\E
也阻止解释,\t
但我只需要解释。所以没有行被删除。
这似乎是一个相当复杂的问题,但我希望你能帮助我。
输出:
apple text1
peach text2
banana text3
melon text4
对于删除以“apple”或“banana”开头的行,我输入:
perl -pe 's/^apple.*\n|^banana.*\n//g'
并且输出是正确的:
peach text2
melon text4
但我也想删除最终的“木瓜”或“芒果”。为了实现这一点,我应用了德摩根定律:
perl -pe 's/^(?!peach).*\n&^(?!melon).*\n//g'
但是什么都没有被删除,因为 while "|" 代表“或”,“&”不起作用。
在 bash perl 命令中,什么符号代表“和”?