Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating file doesnt work

Status
Not open for further replies.

TheDauntless

Programmer
Feb 26, 2008
14
BE
Hi,

I'm trying to do something really simple, but it just won't work: How can I create an empty file (fe .txt), and close it without writing anything in it?

I've tried this:
Code:
open(ORDER, ">$name") or die $!;
But then it says:
No such file or directory at C:\Documents and Settings\Jeroen\My Documents\School\IW\Perl\Amazon.pl line 172, <STDIN> line 1.

I've tried a lot of other things, like:
Code:
open(ORDER, "+>", "$name") or die $!;
But they all give the same result.

What am I doing wrong ??
 
what does $name have in it?
change your die to
or die "$name : $!\n";
or something

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
I kind of fixed it.

$name was made by concatenating a string with the result of a function that got the date(), but apparently, getting the date takes some time to work? (The prints before the open() command were printed after the error :S).

I removed the date and now it works :)

Sorry for the trouble
 
It doesn't really work like that. It will do one thing at a time and not continue until the first thing is done. You might want to play with it a little more and see what was breaking because it will probably come back to byte you in the rear :)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
That's what I thought... Maybe it was just Komodo screwing up the outputs / errors ... :)
 
What does the date format look like? It could contain characters that cannot be used in file names.
 
I can't find a backup file which has the getDate() still in it. But there's a change that I did indeed use a character that's not aloud in filenames... Too bad I can't tell for sure.

Thanks for all your help though!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top