in reply to Re: Five digit number display separately
in thread Five digit number display separately

print "insert 5 digit number:\n"; $string = <STDIN>; for ($i=1; $i<=5; $i++) { $var = substr($string,$i-1,1) Print "$var\n"; } For this i am getting output as: 1 2 3 4 5 someone help me out i am new to perl i need output as 1 22 333 4444 55555
  • Comment on Re^2: Five digit number display separately

Replies are listed 'Best First'.
Re^3: Five digit number display separately
by choroba (Cardinal) on Sep 04, 2013 at 21:35 UTC
    You are almost there. The only thing missing is to repeat each digit. For that, you can include another loop, or use the repetition operator as adviced in my first reply to your question.

    Also, please use <code> ... </code> tags for code and data samples to improve readability.

    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ