McSvenster has asked for the wisdom of the Perl Monks concerning the following question:
I have a script where I want to put a list of files into an array. I tried it as easy as:
my @dateiliste = `ls $datenDir/*.xml`;
This leaves the script running forever doing nothing. To make sure it is this line of code I added :
print LOGFILE "listing des verz. $datenDir\n"; my @dateiliste = `ls $datenDir/*.xml`; my $s = @dateiliste; print LOGFILE "$s Dateien im verz. $datenDir\n";
In my logfile I find everything until "listing des verz. /tmp". The script is running and running and pretyy sure will be running even after I become a monk.
So I tried directly in terminal:
perl -e '$dd = "/tmp";@a = `ls $dd/*.xml`;$s = @a;print "$s Dateien";'
Sure enough this works fine and gives the exspected answer.
So why is the backtick-ls working with perl -e but not within a script?
Thanks in advance,
Mc
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: file listing within skript not working
by moritz (Cardinal) on Jan 30, 2013 at 10:39 UTC | |
by McSvenster (Novice) on Jan 30, 2013 at 11:04 UTC | |
by vinoth.ree (Monsignor) on Jan 30, 2013 at 11:42 UTC | |
by McSvenster (Novice) on Jan 30, 2013 at 11:59 UTC |