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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.