You've got some problems in the code which may be tripping you up. The loop
{ local $/ = 'undef';
foreach $line (<AWKSH>) {
(@glob) = glob("/home/passwd.*");
}
}
Looks like it has several problems.
- $/ isn't set to undef, it's set to a string containing the word 'undef'. So the code is looking for lines separated by the word 'undef'. As it turns out, there is probably no word 'undef' in the file, so it does slurp the whole file anyway, looking for the 'undef' separator, but you should fix it anyway.
- You would set it to undef (or just leave nothing assigned to it which is the same thing) if you wanted to slurp the whole file into a single scalar variable. However you're reading it with <AWKSH> in the array part of a "for" loop, assingning it to $line on each cycle. The whole file get's slurped into the first element on the for loop, so the for loop executes just once, with the whole ouput of the pipe in $line.
- It's good that the for loop only executes once, since assigning the same thing to @glob each time around the loop would just do the same thing over again.
- The whole pipe output has been put in $line, but then we exit the for loop and it disapears, since its scope is limited to the for loop. (It's equivalent to "foreach my $line (<AWKSH>)"
If you're using this code and are stucck, fixing the items above may get you moving again, along with the advice given by others on data structures.