Really V.V.Easy Question.

I need to execute DIR/W from my perl script and send the output to a file -not to the scren-.Can you help please. Thanx.


ParisAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
flivaudaConnect With a Mentor Commented:
open(LS, "dir /w c:\mypath |");
open (OUTFILE, "out.txt");
while ($ln = <LS>)
{
  print OUTFILE "$ln";
}
close (LS);
close (OUTFILE);

0
 
ozoCommented:
print FILE `DIR/W`;
0
 
ozoCommented:
#that's equivalent to
open(LS, "dir /w c:mypath |");  #quoting the "m" with "\m" does nothing
open (OUTFILE, "<out.txt");  #you are opening OPTFILE for reading, not writing
while( <LS> ){
  print OUTFILE;  #quoting "$in" is unnecessary, it's the same as printing $in
}
0
 
flivaudaCommented:
I know that you dont have to assign it to anything I jsut like having access to my variables, in case I want to change it later on, so it is just habit
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.