Advertisement
digimer

Untitled

Aug 15th, 2015
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.75 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))
  17. {
  18.         print "The answer is: ";
  19.         for (0..$num1)
  20.         {
  21.                 print " $name1";
  22.         }
  23.         print "\n";
  24. }
  25. else
  26. {
  27.         print "Your input appears to be malformed. The number must be a digit only and the name can not be blank.\n";
  28. }
  29.  
  30. =pod
  31.  
  32.   0 root@lemass:/home/digimer# /tmp/foo
  33.  
  34. Input the number:4
  35. Input the name:super
  36. num1: [4], name1: [super]
  37. The answer is:  super super super super super
  38.  
  39. =cut
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement