in reply to Creating comma-delimited lists
Untested code:
It's probably not the best, but it might work. Update:Fixed some off-by-one errors caused by using $#foo@thingsicouldknow = ('this','that','the other','the last thing'); @iknowthat = (0,1,3); #this, that, and last thing # now print the things I know... @thingsiknow = @thingsicouldknow[@iknowthat]; print "I know about " print join(', ',@thingsiknow[0..@thingsiknow-2]); print ", and", @thingsiknow[-1] if @thingsiknow > 1; print ".\n".
This version should not print the "and" if you only know one thing.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: Creating comma-delimited lists
by myocom (Deacon) on Aug 24, 2000 at 01:09 UTC |