Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I am unable to do this in PERL although this i can do easily in C#.
The problem is like this:

I have a file name Eg: C:\foo\tempfolder\testfolder\data.txt
and now i use the data.txt file extract some data from it and then write it back to another file with file name data_extract.txt
My perl".pl" file is in another folder which means i cannot just give "data_extract.txt" as my destination file name as this will create in the folder of my pl file.
how can i get the file name as C:\foo\tempfolder\testfolder\data_extract.txt
I hope my explanation is clear.
Posted

1 solution

You can pass path separately and source and destination file names separately. Like following

PERL
$Path = "C:\\foo\\tempfolder\\testfolder\\";
$SourceFile = $Path . "data.txt";
$DestinationFile = $Path . "data_extract.txt";

open ($SFILEHANDLE, '<', $SourceFile) or die $!;
open ($DFILEHANDLE, '>', $DestinationFile) or die $!;
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900