Date: Sat, 22 Sep 2001 17:54:29 GMT From: friedman@math.utexas.edu (Chas Friedman) Subject: Re: extra newline in s command Message-Id: <3baccf85.64409309@news.itouch.net> On Sat, 22 Sep 2001 17:23:40 GMT, laura_fairhead@my-deja.com (laura fairhead) wrote: >Hi, > >Can anyone explain to me why I'm getting extra >newlines inserted with the s/// command in this >script; > >open(FILE,qq[patternfile]) >@k=(qq[0000],) >while(<>){ > /(\d{4})/&& $1<=$#k && s/$1/$k[$1]/ > print > } > > >Every line that has an s/// done on it has >an extra newline and I don't see why it's >doing that. > >It is suppossed to replace occurances of 4 digit >numerics with what is on that line in 'patternfile' >This is my 1st attempt at 'perl' so pleaze be >easy on me.... is this a reasonable way of doing >this or is there a better one? Also, can I read a file >into an array in just one command? > >thanx > >-- >: ${L:-aura} # http://lf.8k.com:80 > Well, your code won't even compile, because several semicolons are missing. Assuming your actual code doesn't have this problem, you are probably getting the newlines from the lines in patternfile. chas