Advertisement
zloyrusskiy

Good code

Apr 5th, 2011
468
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.20 KB | None | 0 0
  1. use 5.012;
  2.  
  3. sub smart_join {
  4.     my $num = shift;
  5.     my @num_arr = 1..$num;
  6.     join '-',$num % 2 ? @num_arr : reverse @num_arr;
  7. }
  8.  
  9. my $num_in = $ARGV[0] // 6;
  10.  
  11. say smart_join( $_ ) for 1..$num_in;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement