<?xml version="1.0" encoding="windows-1252"?>
<node id="891674" title="Re: arrays and loop through array" created="2011-03-06 07:33:27" updated="2011-03-06 07:33:27">
<type id="11">
note</type>
<author id="664508">
philipbailey</author>
<data>
<field name="doctext">
&lt;p&gt;You could use [doc://eval], as follows: &lt;/a&gt;

&lt;c&gt;#!/usr/bin/perl

use warnings;
use strict;

my $str = "1, 2 ,3, 4,6 -10,11 - 15,16, 17";

$str =~ s/\s+//g;
$str =~ s/-/\.\./g;
my @arr = eval $str;

for (@arr){
    my $i = $_;
    print "==&gt;&gt;&gt; $i\n";
}&lt;/c&gt;

&lt;p&gt;You need to be very sure that you have cleaned up arbitrary user input before using eval in this way.&lt;/p&gt;
</field>
<field name="root_node">
891672</field>
<field name="parent_node">
891672</field>
</data>
</node>
