#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    5
    Rep Power
    0

    Adding a new line after loop


    How can I add a new line after the for loop. Right now, the program generates a random password on the same line as the command line when executing it in the terminal

    print "Enter a seed number:\n";

    $s = <STDIN>;

    srand($s ^ time);

    @c=split(/ */, "bcdfghjklmnprstvwxyz");
    @v=split(/ */, "aeiou");

    for ( $i = 1; $i <=4; $i += 1 ) {
    print $c[int(rand(20))], $v[int(rand(5))]
    }
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Posts
    830
    Rep Power
    496
    Try this:

    Perl Code:
    print $c[int(rand(20))], $v[int(rand(5))], "\n";
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    5
    Rep Power
    0
    I did try that. Unfortunately that puts each syllable onto a new line, so you get something like:

    Enter a seed number:
    9
    na
    ru
    jo
    wo
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Apr 2009
    Posts
    1,930
    Rep Power
    1225
    How can I add a new line after the for loop.
    Simple, add a print statement after the loop.
    Code:
    print "\n";
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    5
    Rep Power
    0
    Ah, so simple indeed. Thank you.

IMN logo majestic logo threadwatch logo seochat tools logo