Link to home
Start Free TrialLog in
Avatar of dwcronin
dwcroninFlag for United States of America

asked on

print spaces without typing them all

Using Perl and hopefully regular expressions, how do I print a specific number of characters like spaces?

For example. I want to make a "for" loop that counts to three and then have the program print out:
1 space then "a"
2 spaces then "a"
3 spaces then "a"
Avatar of Tintin
Tintin

for my $i (1..3) {
  printf "%${i}s\n", 'a';
}
ASKER CERTIFIED SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial