putting arrays in arrays!?!? 
Author Message
 putting arrays in arrays!?!?

hi,

in first
                        I'm new to perl!
in second
                    I'm hopelessly lost

I want to put the content of an array in an array like this and addititonaly

$some_value = '4' ;
$some_more_value = '5';

and afterwards the output should look like this
1
2
3
4
5

... can somebody give me a hand with this??

thx

felix



Tue, 23 Dec 2003 00:46:48 GMT  
 putting arrays in arrays!?!?

Quote:

>                    I'm hopelessly lost

No you're not.

Quote:
>I want to put the content of an array in an array like this and addititonaly

                              ^^^^^^^^

Quote:
>scalar values


That is putting the contents of a list into an array. Perl FAQ, part 4:

   "What is the difference between a list and an array?"

Quote:
>$some_value = '4' ;
>$some_more_value = '5';


>and afterwards the output

Err, your code above does not make any output...

Quote:
>should look like this
>1
>2
>3
>4
>5

>... can somebody give me a hand with this??

You do not need a hand with it. It works as you have it.

Did you try it?

--
    Tad McClellan                          SGML consulting

    Fort Worth, Texas



Tue, 23 Dec 2003 00:10:27 GMT  
 putting arrays in arrays!?!?

Quote:
> hi,

> in first
>                         I'm new to perl!
> in second
>                     I'm hopelessly lost

> I want to put the content of an array in an array like this and addititonaly
> scalar values

> $some_value = '4' ;
> $some_more_value = '5';

Why are you quoting '4' and '5' but not 1, 2, 3?

Why, yes.  That's how it's done.

Quote:
> and afterwards the output should look like this
> 1
> 2
> 3
> 4
> 5

> ... can somebody give me a hand with this??


Have you tried your own code?  It does exactly what you want.  The
only objection would be to the variable in all-caps.

Anno



Tue, 23 Dec 2003 01:05:40 GMT  
 putting arrays in arrays!?!?

Quote:
> hi,

> in first
>                         I'm new to perl!
> in second
>                     I'm hopelessly lost

> I want to put the content of an array in an array like this and addititonaly
> scalar values

> $some_value = '4' ;
> $some_more_value = '5';

Why are you quoting '4' and '5' but not 1, 2, 3?

Why, yes.  That's how it's done.

Quote:
> and afterwards the output should look like this
> 1
> 2
> 3
> 4
> 5

> ... can somebody give me a hand with this??


Have you tried your own code?  It does exactly what you want.  The
only objection would be to the variable name in all-caps.

Anno



Tue, 23 Dec 2003 01:06:51 GMT  
 putting arrays in arrays!?!?

(snipped)

Quote:
> I want to put the content of an array in an array like this and addititonaly
> scalar values

> $some_value = '4' ;
> $some_more_value = '5';

> and afterwards the output should look like this
> 1
> 2
> 3
> 4
> 5

Add a newline character  \n  to each value directly,
or indirectly during a plaintext print.

You are missing a semicolon after your BIG_ARRAY assignment.

Godzilla!



Tue, 23 Dec 2003 01:51:51 GMT  
 putting arrays in arrays!?!?


Quote:

> >                    I'm hopelessly lost

> No you're not.

> >I want to put the content of an array in an array like this and
addititonaly
>                               ^^^^^^^^
> >scalar values


> That is putting the contents of a list into an array. Perl FAQ, part 4:

>    "What is the difference between a list and an array?"

> >$some_value = '4' ;
> >$some_more_value = '5';


> >and afterwards the output

> Err, your code above does not make any output...

> >should look like this
> >1
> >2
> >3
> >4
> >5

> >... can somebody give me a hand with this??

> You do not need a hand with it. It works as you have it.

> Did you try it?

> --
>     Tad McClellan                          SGML consulting

>     Fort Worth, Texas

ARGH!!! .... I found the mistake ... in another part of the script

        BUT THX A LOT TO ALL!!!
felix



Tue, 23 Dec 2003 14:59:15 GMT  
 putting arrays in arrays!?!?

Quote:
> I want to put the content of an array in an array like this and
addititonaly
> scalar values

> $some_value = '4' ;
> $some_more_value = '5';


> and afterwards the output should look like this
> 1
> 2
> 3
> 4
> 5

It is right! This is natural perl joining of arrays...

You must use array references to work with arrays into arrays:







    print $a_element;
    }
  }

Saludos, RC



Tue, 23 Dec 2003 19:24:06 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. HELP: putting an @array into an %array???

2. URGENT: Hash in Hash, Array in Array, Array in Hash, Hash in Array

3. array of arrays of arrays

4. Separating array into alphabetical array of arrays

5. putting string on top of array

6. Parse all xml tags and put them in an array

7. putting renamed array elements into a table

8. how to put newlines on arrays

9. Putting/accessing an object from an array - help!

10. Get directory only once and put it in array with File::Find

11. How to put array name in a variable?

12. help putting each page of report in to its own array

 

 
Powered by phpBB® Forum Software