On Mon, 2006-07-24 at 12:40 -0400, Ryan Moszynski wrote:
> Is there a way to make my commented 'foreach" line act the same as the
> line above it?
> 
Sure.

> 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;
# In the previous statement, you're initializing a 1024
# who's values are all undefined
> # my $list4 = "0..10,33..43,100..111";

# use an array instead of a scalar
my @list4 = ( 0..10, 33..43, 100..111 );

> 
>     #foreach (0..10,33..43,100..111){
>     #foreach ($list4){
     foreach (@list4) {
> 
>     $array[$_] = $_;
> 
# this next statement is going to print a bunch of nothing 
# useful as there are no values in the array
>     print "array--$array[$_]-- --$_--\n";
> 
> }
> ###########
> 

HTH

-- 
Joshua Colson <[EMAIL PROTECTED]>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to