----- Original Message ----- From: "Tom Allison" <[EMAIL PROTECTED]> To: "beginners perl" <beginners@perl.org> Sent: Friday, August 26, 2005 4:49 PM Subject: map/grep and arrays
> I keep getting hung up on what I think would be a simple problem. > > I was to do approximately this: > > Given an array of "stuff" print them out > print join(",", @row),"\n"; > > works great until your array elements contain dumb characters like \n\r > somewhere in the string (not always at the end!). > > Initially I thought I could do: > > print join(",", map(s/[\r\n]+//g, @row)), "\n"; > print join(",", map{s/[\r\n]+//g} @row), "\n"; > > but I get output like: > ,,2,, > ,,,, > telling me how many of these I actually matched... > > I can't be that far off, can I? > Try print join(",", map{$_=s/[\r\n]+//g} @row), "\n"; Manav -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>