in reply to system call error
my @elf_files = system("ls"); #or backtiks
Your code doesn't do what you think it does. See Why can't I get the output of a command with system()?. Tutorials->Getting Started with Perl/Basic debugging checklist. Basic debugging could have simply been printing the values before you used them. In the chatterbox Corion provided you with a solution reporting the command actually being run on failure.
Adding:
use strict; use warnings;
generates:
Use of uninitialized value in concatenation (.) or string at ./derp.pl + line 8. readelf: Warning: Nothing to do.
Rather than just:
readelf: Warning: Nothing to do.
You code doesn't cater for all use cases, e.g. if there's a sub directory:
readelf: Error: 'ffmpeg_sources' is not an ordinary file
You should consider not shelling out and just using perl to handle this, opendir, readdir, grep, or modules like Path::Tiny which provide simpler ways of doing this.
Update: for completeness, the only line of code offered in the chatterbox was:
system("readelf -sW $var | awk '{print \$NF}'");
|
|---|