in reply to Array indexing and string manipulation

my @array = ("|", "|", "|", "|", "", "|", "|"); print join '', map { my $foo = shift @array ? $_ : lc } split '', 'ASD +FGHJ';

Replies are listed 'Best First'.
Re^2: Array indexing and string manipulation
by tobyink (Canon) on Mar 26, 2012 at 16:33 UTC

    This is quite a nice technique. It's worth pointing out though, that it has a side-effect of dismantling @array, so you should make a copy of @array first if you were planning on using the array again.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re^2: Array indexing and string manipulation
by Anonymous Monk on Mar 26, 2012 at 16:34 UTC

    Worked like a charm, thanks. The first reply for some reason did not and returned all upper case letters. Seems I don't know perl as good as I thought ;].

Re^2: Array indexing and string manipulation
by Anonymous Monk on Mar 27, 2012 at 10:37 UTC
    Any idea how to change it to catch " " instead of ""? Thanks