• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Can somebody tell me how to create a file using perl?

Are you wanting to write to the file, append it, or input data from it? I'm not the best at perl, but I'll give it a try.

Try this: open (OUTFILE, ">>$path/$filename");
 
hey minendo, thanks for the help... for whatever reason it is working now with the original code 😕

but yea, i was talking about creating a file... i think the single greater than symbol is right for that?
 
Gopunk, I believe the dual greater than symbols will create a file if it does not exist while the single greater than sign will append any new output to an existing file... but don't quote me on that 🙂
 
If MODE is '<' or nothing, the file is opened for input. If MODE is '>', the file is truncated and opened for
output, being created if necessary. If MODE is '>>', the file is opened for appending, again being created if necessary.


From the perlfunc manpage section for open, so > should work.
 


<< If MODE is '<' or nothing, the file is opened for input. If MODE is '>', the file is truncated and opened for >>



I sit corrected!
 
open (OUTFILE, "filename"); --> open a file for read
open (OUTFILE, ">filename"); --> open a file to write. if the file exist, it will be replaced
open (OUTFILE, ">>filename"); --> open a file to write. if the file exist, it will append to the end of file

both 2 and 3 created the file if it does not exist yet
also, remember that you will need to have write permission to successfully run 2 and 3

for 1, it only works if the file exist

might also want to consider checking the return value of open(), since it may just return NULL if file doesn't exist (case 1) or if you don't have write permission (2 and 3)

-947-
 
Back
Top