我试图在嵌套的for/foreach循环中使用哈希.见源
用strict它说
Global symbol "$mapping" requires explicit package name at ./test2.pl line 39.
Execution of ./test2.pl aborted due to compilation errors.
Run Code Online (Sandbox Code Playgroud)
没有strict,
Use of uninitialized value $mapping in hash element at ./test2.pl line 46, <$fh> line 8.
Use of uninitialized value in concatenation (.) or string at ./test2.pl line 46, <$fh> line 8.
Run Code Online (Sandbox Code Playgroud)
print $hashref->{$mapping} 在输出中为空.
错误是什么?
我试过安装一个python模块:
virtualenv .
source bin/activate
pip install utmp
Run Code Online (Sandbox Code Playgroud)
似乎安装:
(wtmp)chris@chris-nb:~/computer/wtmp$ find -iname utmp
./bin/utmp
./lib/python2.7/site-packages/utmp
Run Code Online (Sandbox Code Playgroud)
但Python说没找到:
(wtmp)chris@chris-nb:~/computer/wtmp$ ./wtmp.py
Traceback (most recent call last):
File "./wtmp.py", line 3, in <module>
import utmp
ImportError: No module named utmp
Run Code Online (Sandbox Code Playgroud)
这是模块问题吗?我做错什么了吗?
如果重要,操作系统就是Ubuntu.
这是重新安装日志:
(wtmp)chris@chris-nb:~/computer/wtmp$ pip install --upgrade --no-deps --force-reinstall utmp
Downloading/unpacking utmp
Downloading utmp-0.4.tar.gz
Running setup.py (path:/home/chris/computer/wtmp/build/utmp/setup.py) egg_info for package utmp
zip_safe flag not set; analyzing archive contents...
flake8.reporter: module references __file__
flake8.tests._test_warnings: module references __file__
flake8.tests.test_integration: module references __file__
Installed /home/chris/computer/wtmp/build/utmp/flake8-2.4.1-py2.7.egg
Searching for …Run Code Online (Sandbox Code Playgroud)