Perl Symbolic Reference

看一些模块的代码,很多时候通过*glob的方式来改变变量或者函数,这种方法称为Symbolic reference。

首先看一下*glob的结构,这个在之前的博文已经讲过,不做细述:

SV = PVGV(0x18d1364) at 0x182aaec
  REFCNT = 2
  FLAGS = (IN_PAD)
  NAME = "test"
  NAMELEN = 4
  GvSTASH = 0x298fc4	"main"
  GP = 0x18b90ac
    SV = 0x0
    REFCNT = 1
    IO = 0x0
    FORM = 0x0  
    AV = 0x0
    HV = 0x0
    CV = 0x0
    CVGEN = 0x0
    LINE = 4
    FILE = "test.pl"
    FLAGS = 0x8
    EGV = 0x182aaec	"test"
运行下边的代码段,察看一下输出对应的ref slot。

print ref \1;
print ref \'testing';
print ref [qw(one, two ,three)];
print ref {};
print ref sub {};
如何给*glob赋值?通过下面的方式,填充Symbol的不同slot,从而使得对应的$test,@test,%test,&test非空。

use Data::Dumper;
use Devel::Peek;

*test = \1;
*test = [qw(one two three)];
*test = {qw(one two three four)};
*test = sub {};

print Dump *test;

$scalar = 1;
*test   = \$scalar;
@array  = 1..4;
*test   = \@array;
%hash   = 1..4;
*test   = \%hash;

print Dump *test;
SV = PVGV(0x18d134c) at 0x182aaec
  REFCNT = 6
  FLAGS = (MULTI,ASSUMECV,IN_PAD)
  NAME = "test"
  NAMELEN = 4
  GvSTASH = 0x298fc4	"main"
  GP = 0x18b9104
    SV = 0x182aadc
    REFCNT = 1
    IO = 0x0
    FORM = 0x0  
    AV = 0x2990d4
    HV = 0x299214
    CV = 0x18b1e7c
    CVGEN = 0x0
    LINE = 4
    FILE = "test.pl"
    FLAGS = 0xe
    EGV = 0x182aaec	"test"
如何使用?use strict情况下有几种方式:
下面的情况直接调用Symbol或者通过our定义直接访问变量,函数无需our定义,总是一个Symbol,可以直接通过名字访问。
use strict;
use Data::Dumper;
use Devel::Peek;

*test = \1;
*test = [qw(one two three)];
*test = {qw(one two three four)};
*test = sub {print "testing\n";};

print $::test;
print %::test;
&test();

our ($test, %test);
print $test;
print %test;
&test;
如果通过一个变量传名字访问另外一个变量,则需要通过下面的方式no strict 'refs'。
no strict 'refs';
print ${'test'};
print %{'test'};
&{'test'};

参考:

perldoc perlref

### Armbian 中命令未找到问题的解决方案 在 Armbian 或其他基于 Debian 的 Linux 发行版中遇到 `command not found` 错误通常是因为缺少相应的软件包或环境配置不正确。以下是针对不同情况的具体处理方法。 #### 1. 更新软件源并安装必要的工具 如果尝试使用某些命令时收到 `command not found` 提示,可能是因为这些命令对应的软件尚未被安装。对于 Armbian 系统而言,默认情况下并不一定预装所有的开发工具和实用程序。因此建议先更新系统的软件库列表: ```bash sudo apt update && sudo apt upgrade -y ``` 这条指令会刷新本地缓存中的可用软件版本信息,并升级已有的软件至最新稳定版[^1]。 #### 2. 安装特定命令所在的软件包 当确认某个具体命令确实不存在于当前环境中时,则需查找其所属的官方软件包名称并通过 APT 包管理器来获取它。例如要解决 `apt-get: command not found` 这样的报错可以这样做: ```bash sudo dpkg --configure -a sudo apt install -f sudo apt install apt-utils ``` 上述操作能够修复潜在依赖关系损坏的情况以及重新安装基本的APT工具集。 而对于像 `vim`, `gcc` 等常用编辑器或编译器类别的缺失,可以直接通过如下方式快速部署它们: ```bash sudo apt install build-essential vim curl git htop tmux zsh jq silversearcher-ag fzf python3-pip nodejs npm yarn docker.io terraform kubectl minikube awscli azure-cli gcloud sdkman-cli rustup dotnet-sdk-go openjdk-17-jdk maven gradle ant cargo go ruby rvm php composer perl cpanminus lua luarocks haskell-stack elixir erlang crystal dmd nim nasm yasm llvm clang bison flex make cmake ninja-build meson pkg-config autoconf automake libtool gettext intltool doxygen graphviz plantuml valgrind strace ltrace tcpdump wireshark ngrep masscan nmap hydra john hashcat sqlmap wpscan nikto dirbuster zaproxy burp-suite-free-edition owasp-zap-baseline security-misc exploitdb metasploit-framework social-engineer-toolkit beef-xss bettercap mitmproxy proxychains privoxy tor polipo squid tinyproxy privoxy torbrowser-launcher tails-installer qubes-os-installation-guide whonix-gateway whonix-workstation hardenedlinux hardening-checklist selinux-apparmor grsecurity paX_tools checksec binwalk radare2 capstone keystone unicornengine angr boofuzz driller fuzzilli jsfunfuzz afl++ libfuzzer honggfuzz syzkaller triton-reil taintbochs s2e klee symbolic-execution concolic-testing binary-ninja idapro ghidra radare2-bindings bindiff patchdiff2 diaphora retdec decompilation reverse-engineering malware-analysis forensics incident-response digital-investigation network-security web-application-security mobile-security cloud-security containerization virtualization sandboxing honeypots pentesting red-teaming blue-teaming purple-teaming threat-hunting vulnerability-assessment risk-management compliance auditing legal issues policy development training education community outreach conferences workshops meetups podcasts blogs books research papers whitepapers case studies best practices guidelines standards frameworks models methodologies tools techniques strategies tactics operations management leadership communication collaboration teamwork project planning organization time management productivity self-improvement personal growth mindset resilience adaptability creativity innovation entrepreneurship business-models startup-strategy market-analysis customer-discovery product-development lean-startup agile-methodology devops continuous-integration delivery pipeline infrastructure-as-code configuration-management monitoring logging alerting performance-tuning scalability reliability availability fault-tolerance disaster-recovery backup-restoration data-protection privacy cybersecurity ethics professional-development career-advice job-search interview-preparation resume-building networking events mentorship coaching peer-support group-study collaborative-learning online-courses tutorials documentation wikis forums mailing-lists slack-discord-channels github-gitlab-bitbucket repositories version-control branching merging pull-request code-review pair-programming test-driven-development behavior-driven-development acceptance-test-driven-development automated-tests unit-tests integration-tests end-to-end-tests property-based-testing mutation-testing static-analysis dynamic-analysis runtime-profiling memory-leak-detection concurrency-debugging race-condition-detection deadlocks-starvation-livelock-prevention deadlock-resolution starvation-fairness scheduling-algorithms resource-allocation deallocation garbage-collection reference-counting smart-pointers weak-reference phantom-reference soft-reference strong-reference finalizer cleanup shutdown-hook lifecycle-hooks initialization-finalization object-oriented-programming functional-programming procedural-programming logic-programming declarative-programming imperative-programming domain-specific-language scripting-language markup-language stylesheet-language query-language template-language macro-language assembly-language low-level-high-level-intermediate languages compilers interpreters transpilers assemblers disassemblers linkers loaders debuggers profilers optimizers analyzers formatters beautifiers linters validators sanitizers obfuscators packagers bundlers minifiers compressors encryptors decryptors signers verifiers authenticators authorizers access-controls permissions roles policies rules constraints conditions expressions statements declarations definitions implementations interfaces inheritance polymorphism encapsulation abstraction composition delegation aggregation association relationships between objects classes structures types primitives generics templates meta-programming reflection introspection annotations attributes metadata serialization deserialization marshalling unmarshalling encoding decoding parsing generating transforming converting translating mapping binding linking referencing dereferencing scoping namespaces modules packages libraries frameworks platforms ecosystems communities organizations institutions enterprises startups non-profits governments agencies universities schools colleges institutes labs centers departments divisions teams groups clubs associations societies foundations
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值