[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Sliced bread (was Re: (NOT solved)Re: why does the shell show commands foolishly...)



On Fri, Nov 09, 2007 at 11:13:54PM -0600, Ron Johnson wrote:
> On 11/09/07 22:40, Ken Irving wrote:
> [snip]
> > Greatest thing since
> > 
> >   $ perl -e '@b=split //,"bread"; print @b[0,1,2,3,4,5], "\n"'
> 
> Is this supposed to print out b-r-e-a-d or
> b
> r
> e
> a
> d

No, just "bread" on a line, after slicing it...  Pretty lame, but
it was the best I could come up with, and couldn't stop myself from
posting it...  Would've looked more sliced as you depict it; maybe:

    $ perl -e '@b=split //,"bread"; print "@b[0..4]\n"'
    b r e a d

(The construct @array[...] in Perl is called an array slice.)

-- 
Ken Irving, fnkci+debianuser@uaf.edu



Reply to: