I figured the chomps did nothing, but I put them in the script after having some earlier problems, which they solved. I left them in figuring that the don't do any harm, and I don't care about execution speed.
Best, Tim
On Dec 15, 2003, at 2:19 PM, Vic Norton wrote:
Try $path = "$INC[0]/sourcefile.txt"; $resultpath = "$INC[0]/results.txt";
I'm not sure what the chomps are for.
Regards,
Vic
At 1:23 PM -0800 12/15/03, Tim Warner wrote:A very basic question, but the answer eludes me: How do I open files in the same directory as my Perl script?
I'm running these scripts from BBEdit and they worked fine under BBEdit 6.5 on OS 9.2. But when I run them under BBEdit 7 on OS 9 or with BBE7.1 in Mac OS X, I get an error when trying to read a file, saying that the file doesn't exist.
I can successfully write files, but they all go to the root volume directory (in OSX). If I move the file I want to read to the root directory, everything works fine.
I tried using File::Spec after reading messages in the [EMAIL PROTECTED] archive, but while I do get lovely paths using it, things still don't work. File::Spec->path(); returns ".", and even if I concatenate that with my filename using File::Spec->catpath(args); I still get bupkiss.
Here's my original script: << #!/usr/bin/perl print STDOUT "starting...\n";
$path = "sourcefile.txt"; chomp; $resultpath = "results.txt"; chomp;
#source file open (SOURCEFILE, $path) or die "Couldn't open $path for reading: $!\n";
#results file open (TARGETFILE, ">> $resultpath") or die "Couldn't open $resultpath for writing: $!\n";
... etc snipped....
Thanks for your help. --Tim
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Tim Warner mailto:[EMAIL PROTECTED]
-- *---* mailto:[EMAIL PROTECTED] | The blues are the roots; everything else is the fruits. | - Willie Dixon *---* http://vic.norton.name
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Tim Warner mailto:[EMAIL PROTECTED]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Salty Dog currently at the bottom of the sea.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
