Thread split funktioniert nicht mit @_? (3 answers)
Opened by lawnmover at 2011-02-17 16:15

Gast lawnmover
 2011-02-17 16:15
#145727 #145727
Hi Leute,

ich arbeite mich gerade in Perl ein und leider macht die split funktion nicht das was sie soll. Zumindest nicht in einer Subroutine. Hier mal der Code villeicht bin ich einfach blind.
Code: (dl )
1
2
3
4
5
6
sub data{
my @parts;
print @_;
@parts = split( /:/, @_);
print "\n" . 'size of parts: ' . $#parts . "\n";
}

das print @_ ist nur um sehen was die Sub bekommt. Hier mal die Ausgabe des Programms:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Vendor: Phoenix Technologies, LTD
Version: 6.00 PG
Release Date: 10/08/2008
Address: 0xE0000
Runtime Size: 128 kB
ROM Size: 1024 kB
Characteristics:
ISA is supported
PCI is supported
PNP is supported
APM is supported
BIOS is upgradeable
BIOS shadowing is allowed
Boot from CD is supported
Selectable boot is supported
BIOS ROM is socketed
EDD is supported
5.25"/360 KB floppy services are supported (int 13h)
5.25"/1.2 MB floppy services are supported (int 13h)
3.5"/720 KB floppy services are supported (int 13h)
3.5"/2.88 MB floppy services are supported (int 13h)
Print screen service is supported (int 5h)
8042 keyboard services are supported (int 9h)
Serial services are supported (int 14h)
Printer services are supported (int 17h)
CGA/mono video services are supported (int 10h)
ACPI is supported
USB legacy is supported
LS-120 boot is supported
ATAPI Zip drive boot is supported
BIOS boot specification is supported

Handle
size of parts: 0


wie man leider sieht ist die Größe des Arrays @parts gleich null. Daher gehe ich davon aus das die split funktion irwas nicht macht... Oder verwende ich die @_ Variable einfach falsch? (Zuweiungen wie my @parts; @parts = @_; brachten mich leider auch nicht weiter.

Noch ein paar Infos über das Programm.
Öffnen einer Datei, setzen des $/ auf 'Handle', while schleife. $_ an Sub, die teilt noch mal auf und gibt $_[3] dann weiter an data. (Kann auch wenn gewünscht den ganzen Code posten.)
Last edited: 2011-02-17 16:19:34 +0100 (CET)

View full thread split funktioniert nicht mit @_?