EchoAngel has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I wanted to generate a list of numbers say example 1 to 200 within a makefile
NumberList := $(shell perl -e 'foreach (1..200){print $_;}');
I'm not sure if I am coding this right ... any help?

Replies are listed 'Best First'.
•Re: Perl Command in Makefile Question
by merlyn (Sage) on Jul 08, 2004 at 15:55 UTC
Re: Perl Command in Makefile Question
by jfroebe (Parson) on Jul 08, 2004 at 16:20 UTC

    Hi EchoAngel

    Adding to Randal L. Schwartz's reply, your perl one liner will produce one big number.. you need to use a space or some other delimiter between the numbers

    perl -e 'print $_ foreach (1..200)'
    Produces:
    1234567891011121314151617181920212223242526272829303132333435363738394 +041424344454647484950515253545556575859606162636465666768697071727374 +757677787980818283848586878889909192939495969798991001011021031041051 +061071081091101111121131141151161171181191201211221231241251261271281 +291301311321331341351361371381391401411421431441451461471481491501511 +521531541551561571581591601611621631641651661671681691701711721731741 +751761771781791801811821831841851861871881891901911921931941951961971 +98199200

    perl -e 'print "$_ " foreach (1..200)'
    Produces:
    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 2 +7 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 5 +0 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 7 +3 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 9 +6 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 11 +4 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 + 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 +149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 1 +66 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 18 +3 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200

    No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

Re: Perl Command in Makefile Question
by iburrell (Chaplain) on Jul 08, 2004 at 16:29 UTC
    If you are Unix, the seq program generates a sequence of numbers. Much faster and simpler to use it instead of Perl.
    NumberList := $(shell seq 1 200)

      Not sure what version of unix you are on, but HP-UX 11.0 does not have seq, so it is not portable.

      --MidLifeXis