Mark VanMiddlesworth <[EMAIL PROTECTED]> writes: > I want to feed the output of an "ls" command into a perl script and > store it as a variable, but I can't seem to figure out how to do > this. How can I get this working? > > thanks, > mark > > p.s. I'm using tcsh on mac os 10.2
I now nothing about OS 10 but have heard its a bsd OS so this should work. You'll get better answers than mine no doubt, but there are quite a lot of ways Ill list a few: None of these are tested... just some ideas tossing it in from outside using the shell ls|my.pl cat my.pl -- #!/usr/bin/perl -w ## process incoming filenames while (<>){ chomp; ## collect each name into array varialb @ls_array push @ls_array,$_; } for(@ls_array){ $filename = $_; ## do something clever with each filename print "$filename\n"; } -- Running the ls from inside perl program #!/usr/bin/perl -w ## Notice the pipe symbol open(PROC,"ls "); while(<PROC>){ ## collect file names push @ls_array,$_; } close(PROC); for(@ls_array){ [...] } Another inside technique @ls_array = qx(ls); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]