in reply to Problem printing contents of file

If all you're telling is true, the only explanation is that ../frame.txt is an empty file. Note that it is a good practice to mention the filename as well. Also, it is a bad practice to use relative filenames unless you know which directory is the current directory when your script is run. Notably, webservers set a different current directory when they run scripts. The following code works for me, but it is not substantially different from your code:

#!/usr/bin/perl -w use strict; #my $filename = '../frame.txt'; my $filename = $0; open my $fh, '<', $filename or die "Couldn't open '$filename': $!"; while (<$fh>) { print "$_\n"; };

Replies are listed 'Best First'.
Re^2: Problem printing contents of file
by ketaki (Acolyte) on Jun 18, 2008 at 06:32 UTC
    you said webservers set a diffrent current directory when they run the script.. probably this could be the reason. how am i to know which current directly are they using?
      how am i to know which current directly are they using?

      Your script can make use of the Cwd module for that. (But, as stated elsewhere, the best approach is to use a full path to frame.txt instead of the relative path that you have been using. When you use a full path it doesn't matter where the current working directory is.)

      Cheers,
      Rob
        its giving me a error 500 when i put the whole path. whats the syntax for putting the full path while opening a file to read?

      Use the getcwd function from Cwd, or, even better, use absolute path names.