in reply to iterating through scalar

to iterate is meant to be done against a list, not a scalar. Or you mean iterate on characters found in a string? This imply to build such list and then iterate over the list.

Please show some effort while asking question.

L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: iterating through scalar
by yedukondalu (Acolyte) on Mar 19, 2015 at 08:37 UTC

    Sorry for asking such question,as i am new to perl. What i need is ,i have a scalar element $name='krishna'.I need to print only any one of the character in the string like i need only 'i' to be printed.

      Maybe something like this:

      c:\@Work\Perl\monks>perl -wMstrict -le "my $name = 'krishna'; print substr $name, 2, 1; " i
      See substr.


      Give a man a fish:  <%-(-(-(-<

        Thanks for your kind reply.