"Ryan Moszynski" schreef: > Can I pass a list as a variable as I am trying to do, or doesn't perl > support that? > > ########### > #!/usr/bin/perl -w > $|=1; > #use strict; > > system "clear"; > my @array = 1024; > my $list4 = "0..10,33..43,100..111"; > > foreach (0..10,33..43,100..111){ > #foreach ($list4){ > > $array[$_] = $_; > > print "array--$array[$_]-- --$_--\n"; > > } > ###########
#!/usr/bin/perl -w # Script-ID: for-list.pl use warnings ; use strict ; my @array ; my $list = '0..10,33..43,100..111' ; for (split ',', $list) { my ($min, $max) = split /\.\./ ; for ($min..$max) { $array[$_] = $_ ; print "$array[$_]\t$_\n" ; } } print "\n-----\n" ; my @list = (0..10,33..43,100..111) ; local ($\, $,) = ("\n", "\n") ; print '<'. scalar @list .'>' ; print @list ; -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>