Associative Array Example
Associative Array Example
- Finding Include Dependencies for source files
- We’re building an associative array where the key is a filename of the source file.
- Using the string concatenation operator to:
- Include the path of header file
- Add a space at the end
# First extract the include lines from each file.
foreach $file (@ARGV) {
open(FILE, $file) || warn "Can't open $file: $!\n";
while () {
if (/^#include\s+["<]([^">]*)[">]/) {
$includes{$file} .= $1 . ' ';
}
}
}
\1