Advertisement
digimer

Untitled

Aug 15th, 2015
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.71 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. print "\nInput the number:";
  7. chomp ( my $num1 = <STDIN> );
  8. print "Input the name:";
  9. chomp ( my $name1 = <STDIN> );
  10.  
  11. $num1  = "" if not defined $num1;
  12. $name1 = "" if not defined $name1;
  13.  
  14. print "num1: [$num1], name1: [$name1]\n";
  15.  
  16. if (($num1 !~ /\D/) && ($name1 ne ""))
  17. {      
  18.         print "The answer is: ";
  19.         print " $name1" x $num1;
  20.         print "\n";
  21. }
  22. else
  23. {
  24.         print "Your input appears to be malformed. The number must be a digit only and the name can not be blank.\n";
  25. }
  26.  
  27. =pod
  28.   0 root@lemass:/home/digimer# /tmp/foo
  29.  
  30. Input the number:4
  31. Input the name:hello
  32. num1: [4], name1: [hello]
  33. The answer is:  hello hello hello hello
  34. =cut
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement