![]() |
|
laziness, impatience, and hubris | |
PerlMonks |
Re: variable mysteryby oko1 (Deacon) |
on Nov 29, 2008 at 00:40 UTC ( #726697=note: print w/replies, xml ) | Need Help?? |
For one thing, your code doesn't run:
For another, all you're doing with that "map" statement is returning (via $_) the return of the substitution statement ('1') rather than the modified value of $_ - printing "@fields" would be instructive here. Lastly, you're explicitly splitting $_ inside your loop; changing the iterator variable is thus going to leave $_ empty, which means that your code isn't going to work. Here's a slightly simpler version of your code, both with an explicit iterator and without:
The output in both cases is:
Update: I just noticed one more thing: you're using "\r" when you're printing - which means that you're going to overwrite every line that you print. This means that you'll only see the last line, plus anything left over (i.e., anything that was past the current last character) from the previous lines. The correct character to use, at leat in the Unix world, is "\n"; for DOS-based systems, "\n\r" is appropriate. -- "Language shapes the way we think, and determines what we can think about." -- B. L. Whorf
In Section
Seekers of Perl Wisdom
|
|