Solved

Really V.V.Easy Question.

Posted on 1998-11-10
4
200 Views
Last Modified: 2010-03-04
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.


0
Comment
Question by:Paris
  • 2
  • 2
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1206137
print FILE `DIR/W`;
0
 
LVL 1

Accepted Solution

by:
flivauda earned 50 total points
ID: 1206138
open(LS, "dir /w c:\mypath |");
open (OUTFILE, "out.txt");
while ($ln = <LS>)
{
  print OUTFILE "$ln";
}
close (LS);
close (OUTFILE);

0
 
LVL 84

Expert Comment

by:ozo
ID: 1206139
#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
 
LVL 1

Expert Comment

by:flivauda
ID: 1206140
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

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Remove Malware code from PHP file 6 90
SIMPLE Perl Regex 1 162
How to strip .csv from file name 9 83
rename outfile before writing 2 74
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question