Advertisement
Guest User

01.pl

a guest
Oct 22nd, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.55 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use 5.010;
  3. # Napisati skript koji sabira 3 cela pozitivna jednocifrena i dvocifrena broja. Brojevi su dati kao argumenti komandne linije. Prikazati grešku na standardnom izlazu ako je broj argumenata neodgovarajući ili je broj van propisanog opsega.
  4.  
  5.  
  6. if ( @ARGV != 3 )
  7.     {
  8.     say "Pogresan broj argumenata";
  9.     exit 1;
  10.     }
  11. else
  12.     {
  13.     $zbir=0;
  14.     while ( @ARGV > 0 )
  15.         {
  16.         if ( $ARGV[0] >= 0  &&  $ARGV[0] <= 99 )
  17.             {
  18.             $zbir+=shift;
  19.             }
  20.         else
  21.             {
  22.             say "Los argument";
  23.             exit 2;
  24.             }
  25.         }
  26.     }
  27. say "$zbir";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement