in reply to Declare array with range operator
If you trust the source, then eval:
c:\test>p1 $ips="30..39,50..59";; @array= eval $ips;; print "@array";; 30 31 32 33 34 35 36 37 38 39 50 51 52 53 54 55 56 57 58 59
otherwise parse:
@a = map{ my( $s, $e ) = split '\.\.'; $s .. $e } split ',', $ips;; print "@a";; 30 31 32 33 34 35 36 37 38 39 50 51 52 53 54 55 56 57 58 59
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Declare array with range operator
by mariognarly (Initiate) on Jul 12, 2011 at 19:22 UTC |