Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!rodney From: rodney@sun.ipl.rpi.edu (Rodney Peck II) Newsgroups: comp.lang.perl Subject: Re: Do be do be do. Message-ID: <=9#&{B*@rpi.edu> Date: 2 Feb 91 04:04:10 GMT References: Organization: Rensselaer Polytechnic Institute, Troy NY Lines: 33 Nntp-Posting-Host: ipl.rpi.edu In article flee@cs.psu.edu (Felix Lee) writes: >I spent fifteen minutes staring at this thing, wondering why it didn't >work right: > sub put { > local($x) = @_; > print $x; > $currentposition += length($x); > } > $currentposition = 1; > $desiredposition = 1; > &put(' ') while $currentposition < $desiredposition; > >It prints one space rather than none. > >Perl semantics are much too toxic for ordinary household use. >-- >Felix Lee flee@cs.psu.edu That's an easy one. you've got the while syntax wrong. I don't know what your version does, but it will most likely _always_ exec put(' ') once and then do something about the while part. The thing you are trying to say is this: while ($currentposition < $desiredposition) { &put(' '); } -- Rodney