Entwickler-Ecke

Off Topic - Perl Systemcommandoutput in Array


bo_91 - Di 12.05.09 19:53
Titel: Perl Systemcommandoutput in Array
Hallo Leute,

Kann jemand von euch perl?

Ich suche nach der möglichkeit das Output von System direkt zeile für zeile in ein array zu bringen... klappt irgendwie nicht...


Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
$messages;
my $pipe;
$command = "cat /var/log/messages | grep \"kernel\"";

open $pipe, system("$command |") or die "FEHLER";

while (<$pipe>){
    push @messages, $_;
}


Resultat:
~ perl log.pl
# sh: -c: line1: syntax error: unexpected end of file
# FEHLER at log.pl line 9 -> line mit open $pipe.....

ich verstehe nicht was falsch ist... dh ich kann eig. kein auch kein perl... bitte dringenst um hilfe