Thread Variablendeklaration (4 answers)
Opened by guest at 2009-03-11 09:08

Gast guest
 2009-03-11 09:08
#526 #526
Hi!

Eine Frage zur Variablendeklaration - macht es einen Unterschied, ob ich "my @array;" oder "my @array = ();" schreibe?

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/perl
use warnings;
use strict;

my @array_1;
if ( ( localtime() )[3] % 2 ) {
        @array_1 = ( 1, 2, 3, 4 );
}
push( @array_1, 5 );
print "@array_1\n";


my @array_2 = ();
if ( ( localtime() )[3] % 2 ) {
        @array_2 = ( 1, 2, 3, 4 );
}
push( @array_2, 5 );
print "@array_2\n";


mod-edit pq: code-tags hinzugefĆ¼gt
Last edited: 2009-03-11 09:55:21 +0100 (CET)

View full thread Variablendeklaration