Blame view

egs/gp/s1/utils/get_split_id.pl 857 Bytes
8dcb6dfcb   Yannick Estève   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  #!/usr/bin/env perl
  
  # 
  # If the command-line argument is 4, this script prints "0 1 2 3";
  # If the command-line argument is 20, it prints 10 through 29.
  # These numbers are used to allocate the names of split-up data 
  # directories.  We make the names this way so that when we use globs
  # to represent filenames with these numbers in, they remain in the correct
  # order.  We don't use leading zeros for this purpose because they don't
  # interact well with bash variable name indexing.
  
  if (@ARGV != 2 || $ARGV[0] !~ m:^\d+$: || $ARGV[0] < 1) {
      die "Invalid command-line arguments (expect the number of splits)";
  }
  
  $n = $ARGV[0];
  $start = 0;
  
  if ($n > 10) { $start = 10; }
  if ($n > 90) { $start = 100; }
  if ($n > 900) { $start = 1000; }
  if ($n > 9000) { $start = 10000; }
  
  for ($x = $start; $x < $start + $n; $x++) {
      print $x . " ";
  }
  print "
  ";